Configuring JSON:API Features
The JSON:API module comes with Drupal core out of the box. It exposes entities as a JSON:API-specification-compliant web API.
Varbase API module assembles a better JSON:API starter kit implementation. With authentication and authorization. Allows for easy ingestion of content by other applications.

A Specification for Building APIs in JSON

If you’ve ever argued with your team about the way your JSON responses should be formatted, JSON:API can be your anti-bikeshedding tool.
Read more at: https://jsonapi.org

Drupal Core JSON:API Module

The JSON:API module is a Drupal-centric implementation of the JSON:API specification. By its own definition, the JSON:API specification "is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests.
Designed to minimize both the number of requests and the amount of data transmitted between clients and servers. This efficiency is achieved without compromising readability, flexibility, or discoverability.

Varbase API Settings

On top of JSON:API settings and configs. Varbase brings more configs for easier accessibility. Extra JSON:API specifications and better API documentation for developers.
Having a permission "Administer Varbase API settings" to access Varbase API settings and generate keys page.
Navigate to "/admin/config/system/varbase/api" to change the default Varbase API settings
Varbase API Settings
Check the expose a "View JSON" or "View API Docs" link in entity operations check boxes to list them in entity operation actions in the content page.

View API Docs and View JSON Entity Operations

    Having a permission "Access View JSON entity operation" to let site admins see the View JSON link in entity operations.
    Having a permission "Access View API Docs entity operation" to let site admins View API Docs link in entity operations.
    Showing or hiding the "View JSON" and "View API Docs" links is based on enabled or disabled JSON:API resource types. Which maps only to active endpoints for entity types and bundles.
View API Docs and View JSON Entity Operations

Auto Enabled JSON:API Endpoints for Entity Types

Select the desired Auto Enabled JSON:API Endpoints for Entity Types. Checked entity types will dynamically re-configured on creation of new entity types or entity config types.
Other not checked entity types will not have a new JSON:API endpoints by default.
Auto Enabled JSON:API Endpoints For Entity Types

Generate keys

Having an advanced authentication and authorization with private and public ssh keys.
The key generation form provided by Simple OAuth doesn't generate unique key names (or allow the user to override the names) and doesn't allow the user to specify the location of the OpenSSL config file. Specifically, the fact that the names are always the same could cause problems on systems where the home directory stores keys for more than one application. So hide the link to that form and users can continue to use the one provided by Varbase API.
Navigate to "/admin/config/system/varbase/api/keys" to generate keys configurations.
Varbase API Settings - Generate Keys

Managing JSON:API Resource Overrides

Use the overwrite operation to overwrite a resource type's configuration. You can revert back to the default configuration using the revert operation.
Navigate to "/admin/config/services/jsonapi/resource_types" for overwriting a resource type's configuration. Revert back to the default configuration using the revert operation.
JSON:API Resource overrides

Browsing OpenAPI Documentation For JSON API

A document (or set of documents) that defines or describes an API. An OpenAPI definition uses and conforms to the OpenAPI Specification.
Path templating refers to the usage of template expressions, delimited by curly braces ({}), to mark a section of a URL path as replaceable using path parameters.
The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic.
An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases.

Varbase API list the the following entity types by default:

    Content Types
    Media
    Taxonomy
Navigate to "/admin/config/services/openapi/swagger/jsonapi" in the site to browse the OpenAPI Documentation.
OpenAPI Documentation - Varbase - JSON API

Example API Endpoint After Installation

    Build a Varbase project website with a local domain http://varbase.local pointing at the path of the project.
    Install all Varbase components, with Extra components and optional components too.
    Make sure that the Varbase API module was enabled.
    Navigate to http://varbase.local/api URL in a any browser. Or use any API testing platforms.
    The API link should show empty list of endpoints. except allowed and default configured by Varbase API.
1
{
2
"jsonapi":{
3
"version":"1.0",
4
"meta":{
5
"links":{
6
"self":{
7
"href":"http:\/\/jsonapi.org\/format\/1.0\/"
8
}
9
}
10
}
11
},
12
"data":[
13
14
],
15
"links":{
16
"media--audio":{
17
"href":"http:\/\/varbase.local\/api\/media\/audio"
18
},
19
"media--file":{
20
"href":"http:\/\/varbase.local\/api\/media\/file"
21
},
22
"media--gallery":{
23
"href":"http:\/\/varbase.local\/api\/media\/gallery"
24
},
25
"media--image":{
26
"href":"http:\/\/varbase.local\/api\/media\/image"
27
},
28
"media--instagram":{
29
"href":"http:\/\/varbase.local\/api\/media\/instagram"
30
},
31
"media--remote_video":{
32
"href":"http:\/\/varbase.local\/api\/media\/remote_video"
33
},
34
"media--tweet":{
35
"href":"http:\/\/varbase.local\/api\/media\/tweet"
36
},
37
"media--video":{
38
"href":"http:\/\/varbase.local\/api\/media\/video"
39
},
40
"media_type--media_type":{
41
"href":"http:\/\/varbase.local\/api\/media_type\/media_type"
42
},
43
"node--landing_page":{
44
"href":"http:\/\/varbase.local\/api\/node\/landing_page"
45
},
46
"node--landing_page_lb":{
47
"href":"http:\/\/varbase.local\/api\/node\/landing_page_lb"
48
},
49
"node--page":{
50
"href":"http:\/\/varbase.local\/api\/node\/page"
51
},
52
"node--varbase_blog":{
53
"href":"http:\/\/varbase.local\/node\/varbase_blog"
54
},
55
"node--varbase_heroslider_media":{
56
"href":"http:\/\/varbase.local\/api\/node\/varbase_heroslider_media"
57
},
58
"node_type--node_type":{
59
"href":"http:\/\/varbase.local\/api\/node_type\/node_type"
60
},
61
"self":{
62
"href":"http:\/\/varbase.local\/api"
63
},
64
"taxonomy_term--blog_categories":{
65
"href":"http:\/\/varbase.local\/api\/taxonomy_term\/blog_categories"
66
},
67
"taxonomy_term--tags":{
68
"href":"http:\/\/varbase.local\/api\/taxonomy_term\/tags"
69
},
70
"taxonomy_vocabulary--taxonomy_vocabulary":{
71
"href":"http:\/\/varbase.local\/api\/taxonomy_vocabulary\/taxonomy_vocabulary"
72
}
73
}
74
}
Copied!
Last modified 1mo ago