All Projects → xiaohutai → Jsonapi

xiaohutai / Jsonapi

Licence: mit
[Bolt Extension] JSON API for Bolt CMS

Projects that are alternatives of or similar to Jsonapi

Jsonapi parameters
Rails-way to consume JSON:API input
Stars: ✭ 50 (-9.09%)
Mutual labels:  api, jsonapi, json
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (+107.27%)
Mutual labels:  api, jsonapi, json
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-3.64%)
Mutual labels:  api, jsonapi, json
Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (+247.27%)
Mutual labels:  api, jsonapi, json
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (+298.18%)
Mutual labels:  api, jsonapi, json
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (+340%)
Mutual labels:  api, jsonapi, json
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (+469.09%)
Mutual labels:  api, jsonapi, json
Bandcamp Api
API wrapper for querying band, album, and track data from bandcamp.com
Stars: ✭ 20 (-63.64%)
Mutual labels:  api, json
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+71878.18%)
Mutual labels:  api, json
Node Quick Mock
🌞 基于Express的mock接口平台
Stars: ✭ 33 (-40%)
Mutual labels:  api, json
Pantry
🥑 Free data storage as a service that allows devs to store JSON for multiple apps & users. A good resource when building personal projects, apps for hackathons, and prototypes alike.
Stars: ✭ 42 (-23.64%)
Mutual labels:  api, json
Geochile
Esta es una api de Geocodificación, para que, con las coordenadas Latitud y Longitud se entregue una lista de ciudades cercanas.
Stars: ✭ 13 (-76.36%)
Mutual labels:  api, json
Movement
Movement is an easier, simpler way to explore and use NIEM. Want to join the Movement and contribute to it? Start here.
Stars: ✭ 19 (-65.45%)
Mutual labels:  api, json
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+1640%)
Mutual labels:  api, json
Telize
High performance JSON IP and GeoIP REST API (IP Geolocation)
Stars: ✭ 774 (+1307.27%)
Mutual labels:  api, json
Spyne
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Stars: ✭ 992 (+1703.64%)
Mutual labels:  api, json
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (+1250.91%)
Mutual labels:  api, json
Realtime Newsapi
Financial News Aggregator - Real Time & Query API for Financial News
Stars: ✭ 34 (-38.18%)
Mutual labels:  api, json
Easyjson
Provides an unified JSON access API, you can adapter any JSON library to Gson, Jackson, FastJson with easyjson。 提供了一个JSON门面库,就像slf4j一样。easyjson本身不做json的操作,完全依赖于底层实现库。可以直接使用Easyjson的API,底层的JSON库随时可切换。也可以使用其中某个json的API,然后通过easyjson适配给其他的json库
Stars: ✭ 54 (-1.82%)
Mutual labels:  api, json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-10.91%)
Mutual labels:  api, json

JSON API

Provides simple JSON access to Bolt's internal data structures. The specification of the JSON responses are based on JSON API.

Enabling this extension adds routes to the application that serves content as JSON rather than HTML. This route defaults to /json, so if, for example, you have a contenttype named entries, then the entry with ID 1 is available under /json/entries/1.

Configuration

In order to enable JSON serving for any contenttype, it has to be added to the extension's configuration file, located at app/config/extensions/jsonapi.bolt.yml.

Note in particular that contenttypes that you don't mention in the configuration file won't be served by the JSON API extension.

Base URL

Overriding the base setting allows you to customize where the API is accessible from. This defaults to /json.

base: '/json'

Contenttypes

Only contenttypes listed under contenttypes in the config will be served; for any other contenttype, the API will return 404 errors.

Besides errors, there are two types of responses you can receive, a list of items or single item. You can customize the fields shown in the responses with list-fields and item-fields respectively.

Both field names and taxonomy names are supported. If a field and a taxonomy share the same names, both will be included. Taxonomy values are always under the taxonomy property under attributes, whereas normal fields can be found directly under attributes.

To use the defaults for a contenttype, just leave its entry empty. This will include all user-defined fields (fields and taxonomies in contenttypes.yml), the ID and its contenttype in the listing, but not any of the base fields that Bolt adds to all contenttypes, such as datecreated.

With JSON API, you can also request which fields are to be returned with ?fields[<contenttype>]=<field1>,<field2>. To limit the options, you can set allowed-fields in order to filter these. At the moment, list-fields and item-fields ignore the allowed-fields setting.

The where-clause setting allows you to set additional conditions that are always set by default.

contenttypes:
    entries:
        item-fields: [ title, slug, teaser, image ]
        list-fields: [ title, slug, teaser, image ]
        allowed-fields: [ title, slug, teaser, image ]
        where-clause:
            status: 'published'
        order: title,-datepublish
    pages:
        # use 'default' settings

Images

For images, you'll get an absolute URL to that asset. By default, this extension adds an absolute URL to a 400x300 thumbnail in the response. By overriding the thumbnail setting, you can set a preferred width and height.

thumbnail:
    width: 400
    height: 300

Headers

To work correctly with other tools that read the JSON generated this extension, it might be necessary to set the correct headers with the response. By default, this extension sets the following:

headers:
    'Access-Control-Allow-Origin': '*'
    'Content-Type': 'application/vnd.api+json'

You can define additional headers as required, or tweak the existing ones.

Queries

This extension implements the JSON API specification, as follows:

URL Description
/{ct} Returns a list of records of the specified contenttype.
/{ct}/{id} Returns a single record of the specified contenttype.
/{ct}/{id}/{relatedtype} Returns a list of records that is related to the specified record with specified id.

where {ct} means {contenttype}, the name of the specified contenttype.

Query Parameters

The list call accepts some extra parameters (in the form of query string parameters appended to the URL):

Option Description
sort Order the list by the specified field. Prefix the fieldname with a minus/hyphen to set the orderering to descending. Example sort=id or sort=-id. Note: Bolt currently does not support sorting on multiple fields.
page[size] Specify the number of items to return. Example: page[size]=10
page[number] To be combined with page[size]: get the n-th page. This is 1-based, so 1 designates the first page. Example: page[number]=1&page[size]=10.
include Fetches all the related records of the specified contenttype(s) of the record(s) in the included field of the JSON response. Separate multiple contenttypes with a comma. Example: include=pages.
fields[] Set the fields that are shown in the response per specified contenttype. Separate multiple fields with commas. Multiple fields[] parameters are possible. Example: fields[entries]=slug,teaser.
filter[] Filter records where a certain field must be equal to the specified {value}. Multiple filter[] parameters are possible. Example: filter[id]=1,2.
contains[] Filter records where a certain field must contain the specified {value}. Multiple contains[] parameters are possible. Example: contains[id]=1,2.

Additional Queries

Besides the basic JSON API features, below are some additional Bolt specific queries that you may find useful:

URL Description
/{ct}/search?q={query} Searches for {query} in a specific contenttype.
/search?q={query} Searches for {query} in all contenttypes.
/menu Returns a list of all menus defined in menu.yml.
/menu?q={name} Returns the menu with the specified name.
/taxonomy Returns a list of all taxonomies defined in taxonomy.yml.
/taxonomy?q={name} Returns the taxonomy with the specified name.

Bolt Translate integration

In order to use this extension with bolt/translate. Set up the translate as usual. Then, for every query, add a _locale parameter, e.g. /pages?_locale=en.

Road Map

  • Better handling of menus.
  • Better handling of taxonomies.
  • Better search.
  • Handle specific fieldtypes:
    • Handle JSON fields.
    • Handle select-contenttype fields.
  • Add hooks for handling specific fieldtypes.
  • Add i18n for detail field in error messages.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].