Skip to content

backdrop-contrib/json_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON API (Entities API)

The json api module allows Backdrop websites to get the entities data into json. The json pattern is base on each field type. This project is aiming to be a improve version of Headless module. APIs can be access either by entity with entity id and/or URL alias.

For example:

This project only support READ only APIs. I will provide some example compare JSON API with Drupal 8 but consider that this project will not allow you to UPDATE or POST.

![alt text][logo] [logo]: http://i.imgur.com/OglUsX1.png

Features:

  • Clean API, without unnecessary data.
  • Flexible API to alter any value of a field type.
  • Node Reference recursive objects.
  • Field Type supported:
    • Date fields
    • Text field
    • Boolean fields
    • Tableset field
    • Email field
    • Node reference field
    • File field
    • Link field

Clean API Example

In the Headless module and Drupal 8 rest module most field show unnecessary information for an external application. For instance, for a image field this will provide all this unncessary information such as: target_id, width, height, title, target_type, target_uuid. In addition, this project will remove the prefix of 'field_' to make name of objects more reable.

Headless Output

field_image: {
	und: [{
		fid: "3",
		langcode: "und",
		uid: "1",
		filename: "image.png",
		uri: "public://image.png",
		filemime: "image/png",
		filesize: "6025",
		status: "1",
		timestamp: "1474524274",
		alt: "",
		title: "",
		width: "414",
		height: "242"
	}]
}

Drupal 8 - REST Output

field_image: [{
	target_id: "1",
	alt: "ddd",
	title: "",
	width: "836",
	height: "72",
	target_type: "file",
	target_uuid: "ee66e307-5a79-4429-bea1-763b1e982273",
	url: "http://127.0.0.1:8088/sites/default/files/2016-09/image.png"
}]

JSON API Output

image: {
	alt: "",
	url: "/files/images.png"
}

JSON API will only provide you the data that you need if you need more you can always alter the function of that field type.

Node Reference recursive objects

In the Headless module and Drupal 8 rest module does not provide you the information about entity reference, or node reference. Instead what it does it provide you the target_id, which required the external application to make another call instead of just showing the data in one API call.

Headless Output

field_reference: {
	und: [{
		nid: "1"
	}]
}

Drupal 8 Output

field_reference: [{
	target_id: "2",
	target_type: "node",
	target_uuid: "684b5878-a284-439d-96ce-e272d31964c2",
	url: "/node/2"
}]

JSON API

reference_post: [{
	post: {
		default_values: {
			title: "Your first post!",
			body: null
		},
		image: null,
		tags: null
	}
}]

JSON API module entity reference(node reference) will create an array of objects which the object name is base on the bundle of the entity that is been load. Also, this will create a object called default_values, which is will contain special fields like "title", "body" in the Node types.

For side-by-side comparation check out these two gist:

Installation

Documentation (Coming Soon)

Additional documentation is located in the Wiki: https://github.com/backdrop-contrib/json_api/wiki/Documentation

Issues (Coming Soon)

Bugs and Feature requests should be reported in the Issue Queue: https://github.com/backdrop-contrib/json_api/issues

Current Maintainers

License

This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.

About

The JSON API module allows Backdrop websites to get entity data into JSON. The JSON pattern is based on each field type.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages