表单: faq
用户: sys
创建日期: 2021-04-19 08:57:08 UTC
更新日期: 2021-04-19 09:45:48 UTC
引用:(Table ID 19, Record ID 6)

问题 :
Shujiuqiu Public API
类别 :
function
答案 :

Overview

The SPA (Shujuqiu Public API) allow you to operate your data through a public API. It is opened for VIP and SVIP users only.

The API is under https://api.shujuqiu.com/spa/v1.

You need an access token to access the API, which can be obtained by the login API.

NPA API has rate limiting in order to improve server performance for all users. We only allow 100/1000 calls per day for VIP/SVIP users respectively. Limits are reset in middle night UTC time.

All API method are POST. Each API returns a JSON data as response. The JSON is a dictionary with

  • status: 'OK'/'ERROR'
  • data: Returned data for OK status, could be empty
  • errors: only for ERROR status, it is an array of json dictionary with
    • code: error code.
    • message: error message.
  • meta: meta information.
    • time: Current UTC time
    • tid: unique transaction ID.
    • version: API version, 1.0.
    • token_limit: 100 for VIP, 1000 for SVIP, 0 otherwise.
    • token_remaining: remaining token of today, access will be denied if no token
    • token_reset: token reset time
    • last_active: last access time

For example:

{
  "status": "OK",
  "meta": {
    "time": "2020-12-24T11:41:34",
    "tid": "1608810094_AisU",
    "version": "1.0",
    "token_limit": 1000,
    "token_remaining": 1980,
    "last_active": "2020-12-24T11:41:34",
    "token_reset": "2020-12-25T00:00:00"
  },
  "data": {
      ......
  }
}

API List

API Note
User
login login to get access token
Table & Records
:table_slug/get_records Get all records of a table
:table_slug/get_records/:record_id Get specific record of a table
:table_slug/create_record Add a new record to the table
:table_slug/import_records Import list of records by CSV file to a table
:table_slug/update_record/:record_id Update specific record of a table
:table_slug/destroy_records Destroy all records of a table
:table_slug/destroy_records/:record_id Destroy specific record of a table

User API

POST /spa/v1/login.json

This API provides login method for get access token.

Params

  • name: user name
  • password: your password

Response

  • access_token: access token for your following requests
  • token_type: bearer
  • expires_in: how many seconds can the access token be valid. After that, you must re-login and update token.

Table API

We provide CRUD APIs for table records. You need table slug for accessing the API, which can be find in the table detail information page (slug URL, e.g. 1or1).

POST /spa/v1/:table_slug/get_records.json

This API provides all records of a table.

Params

NA

Response

  • records: array of records, the record structure is defined by your table schema.

POST /spa/v1/:table_slug/get_records/:record_id.json

This API provides record information specified by record ID

Params

NA

Response

  • record: the record structure is defined by your table schema.

POST /spa/v1/:table_slug/create_record.json

This API add a new record to the table

Params

  • record: the record structure is defined by your table schema.

Response

  • record: ID assigned

POST /spa/v1/:table_slug/import_records.json

This API add a list of new records to the table by CSV file

Params

  • file: CSV file, with first line as table column name, each row for a record respectively.

Response

NA

Example

# NOTE: do not use -H 'Content-Type:application/json'
curl -i -H "Accept: application/json" -H 'Authorization: Bearer your_access_token' -X POST -F "file=your_file.csv" "https://api.shujuqiu.com/spa/v1/:table_slug/import_records.json"

POST /spa/v1/:table_slug/update_record/:record_id.json

This API update a specified record

Params

  • record: the record structure is defined by your table schema.

Response

  • record: the record structure is defined by your table schema.

POST /spa/v1/:table_slug/destroy_records.json

This API destroy all records of a table

Params

NA

Response

NA

POST /spa/v1/:table_slug/destroy_records/:record_id.json

This API destroy a record specified by ID

Params

NA

Response

NA

标签: