datoji - minimal JSON RESTful storage service.

栏目: IT技术 · 发布时间: 4年前

内容简介:A FREE RESTful HTTP based JSON API. It lets you create, read, update, delete and search JSON data over HTTP APIs. Ideal for small hobbies projects, MVP or just for fun, where you don't need to create your personal data storage.All API access is over HTTPS,

DatoJi

A FREE RESTful HTTP based JSON API. It lets you create, read, update, delete and search JSON data over HTTP APIs. Ideal for small hobbies projects, MVP or just for fun, where you don't need to create your personal data storage.

Schema

All API access is over HTTPS, and accessed from https://datoji.dev . All data is sent and received as JSON.

Blank fields are included as null instead of being omitted.

All timestamps return in ISO 8601 format:

YYYY-MM-DDTHH:MM:SSZ

All responses follow the JSON:API guidelines:

JSON:API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests.

JSON:API is 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.

{
  "data": {
    "type": "entry",
    "id": "1",
    "attributes": {
      // ... this entry's attributes
    },
    "relationships": {
      // ... this entry's relationships
    }
  }
}

Pagination

Requests that return multiple items will be paginated to 20 items by default. You can specify further pages with the ?page parameter. Pagination information is available inside headers . Example:

Current-Page: 1
Per-Page: 20
Link:<https://datoji.dev/packs/{PACK_ID}/entries?page=1>; rel="first", <https://datoji.dev/packs/{PACK_ID}/entries?page=24>; rel="last"
Total: 464

Documentation

Authentication

API uses OAuth 2.0 token for user authorization and API authentication. Applications must be authorized and authenticated before they can fetch data.

curl -X POST 'https://datoji.dev/tokens' -H 'content-type: application/json'
{
  "data": {
    "id": "b14e1665-5ab3-4b71-a669-b6280d64147e",
    "type": "token",
    "attributes": {
      "key": "uBrcpRP3QVgEJeuffuENPeSc2ObAaGoO",
      "created_at": "2020-06-12T12:51:18.971Z"
    }
  }
}

Note

You must use Authorization: Token 80-Pk8MtTMLXT_ThBaCDuDtF1eTyVmQj header for ALL requests.

CRUD PACKS

Create

A Pack is a container of all the entries. Before you can create the entries you must create the container to get the ID with which you can make the calls.

curl -X POST 'https://datoji.dev/packs' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'
{
  "data": {
    "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
    "type": "pack",
    "attributes": {
      "entries_count": 0,
      "active": true,
      "created_at": "2020-06-11T14:22:12.354Z",
      "updated_at": "2020-06-11T14:22:12.354Z"
    }
  }
}

Read

curl -X GET 'https://datoji.dev/packs/{PACK_ID}' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'

Clear

With the clear method you can clean the pack from all entries.

curl -X POST 'https://datoji.dev/packs/{PACK_ID}/clear' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'

Delete

With the clear method you can clean the pack from all entries.

curl -X DELETE 'https://datoji.dev/packs/{PACK_ID}' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'

CRUD ENTRY

Create

curl -X POST 'https://datoji.dev/{PACK_ID}/entries' \
    -H 'content-type: application/json' \
    -H 'Authorization: Token {KEY}' \
    -d '{ "entry": { "repo": "davidesantangelo/datoji", "private": false, "stargazers_count": 0 } }'
{
  "data": {
    "id": "04b7992a-40de-496b-a994-a661a9893df7",
    "type": "entry",
    "attributes": {
      "data": {
        "repo": "davidesantangelo/datoji",
        "private": "false",
        "stargazers_count": 0
      },
      "created_at": "2020-06-11T14:37:34.857Z",
      "updated_at": "2020-06-11T14:37:34.857Z"
    },
    "relationships": {
      "pack": {
        "data": {
          "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
          "type": "pack"
        }
      }
    }
  }
}

You can also create multiple records at once by passing an array.

curl -X POST 'https://datoji.dev/{PACK_ID}/entries/bulk' \
    -H 'content-type: application/json' \
    -H 'Authorization: Token {KEY}' \
    -d '{ "entries": [{ "repo": "davidesantangelo/datoji" },{ "repo": "davidesantangelo/tuns" },{ "repo": "davidesantangelo/emailhunter" }]}'

The result in case of success is an array of IDs.

[
  "6403b952-ce7d-4759-96d9-c8a913e166ec",
  "5993d6b2-16cd-4d78-a7c8-2aba0f27af0d",
  "b5861049-7c4d-485d-b795-669b9578b78d"
]

Read

Use HTTP GET to read all the records or a single record.

You can also specify a param &order=[asc/desc] by created_at field. Can be one of asc or desc. Default: desc.

curl -X GET 'https://datoji.dev/packs/{PACK_ID}/entries' -H 'Authorization: Token {KEY}'
{
  "data": [
    {
      "id": "beb31992-0268-48b4-b5bc-b2cad0add5c7",
      "type": "entry",
      "attributes": {
        "data": {
          "repo": "davidesantangelo/datoji",
          "private": "false",
          "stargazers_count": 0
        },
        "created_at": "2020-06-11T14:59:00.581Z",
        "updated_at": "2020-06-11T14:59:00.581Z"
      },
      "relationships": {
        "pack": {
          "data": {
            "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
            "type": "pack"
          }
        }
      }
    },
    {
      "id": "b858bf82-1abf-4cb0-a9e0-2a59f1b7f30d",
      "type": "entry",
      "attributes": {
        "data": {
          "repo": "davidesantangelo/feedirss-api",
          "private": "false",
          "stargazers_count": 326
        },
        "created_at": "2020-06-11T14:37:08.293Z",
        "updated_at": "2020-06-11T14:37:08.293Z"
      },
      "relationships": {
        "pack": {
          "data": {
            "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
            "type": "pack"
          }
        }
      }
    }
  ]
}
curl -X GET 'https://datoji.dev/packs/{PACK_ID}/entries/{ENTRY_ID}' -H 'Authorization: Token {KEY}'
{
  "data": {
    "id": "04b7992a-40de-496b-a994-a661a9893df7",
    "type": "entry",
    "attributes": {
      "data": {
        "repo": "davidesantangelo/feedirss-api",
        "private": "false",
        "stargazers_count": 326
       },
      "created_at": "2020-06-11T14:37:34.857Z",
      "updated_at": "2020-06-11T14:37:34.857Z"
    },
    "relationships": {
      "pack": {
        "data": {
          "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
          "type": "pack"
        }
      }
    }
  }
}

Update

Use HTTP PUT to update record one by one. Please note that this will not patch the record, it is full update.

curl -X PUT 'https://datoji.dev/packs/{PACK_ID}/entries/{ENTRY_ID}' \
    -H 'content-type: application/json' \
    -H 'Authorization: Token {KEY}' \
    -d '{ "entry": { "repo": "davidesantangelo/datoji", "private": true, "stargazers_count": 10 } }'
{
  "data": {
    "id": "04b7992a-40de-496b-a994-a661a9893df7",
    "type": "entry",
    "attributes": {
      "data": {
        "entry": {
          "repo": "davidesantangelo/datoji",
          "private": true,
          "stargazers_count": 10
        }
      },
      "created_at": "2020-06-11T14:37:34.857Z",
      "updated_at": "2020-06-11T14:43:45.153Z"
    },
    "relationships": {
      "pack": {
        "data": {
          "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
          "type": "pack"
        }
      }
    }
  }
}

Delete

To delete a specific record use HTTP DELETE, you will receive in case of success a 204 No Content code.

curl -X DELETE 'https://datoji.dev/packs/{PACK_ID}/entries/{ENTRY_ID}' -H 'Authorization: Token {KEY}'

Search

You can perform searches within the dataset.

Supporting:

  • unquoted text: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.

  • "quoted text": text inside quote marks will be converted to terms separated by <-> operators, as if processed by phraseto_tsquery.

  • OR: logical or will be converted to the | operator.

  • -: the logical not operator, converted to the the ! operator.

curl -X GET 'https://datoji.dev/packs/{PACK_ID}/search?q=datoji' -H 'Authorization: Token {KEY}'
{
  "data": [
    {
      "id": "b858bf82-1abf-4cb0-a9e0-2a59f1b7f30d",
      "type": "entry",
      "attributes": {
        "data": {
          "repo": "davidesantangelo/datoji",
          "private": true,
          "stargazers_count": 10
        }
        "created_at": "2020-06-11T14:37:08.293Z",
        "updated_at": "2020-06-11T14:37:08.293Z"
      },
      "relationships": {
        "pack": {
          "data": {
            "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
            "type": "pack"
          }
        }
      }
    }
  ]
}

Limitations

  • Requests are rate-limited to 400 per 5 minutes per IP address.
  • There is no limit imposed on the number of entries or packs records, but please don't abuse it since it's a service i offer free of charge.

Built With

  • Ruby on Rails — Our back end API is a Rails app. It responds to requests RESTfully in JSON.
  • PostgreSQL — Our main data store is in Postgres.
  • Redis — We use Redis as a cache and for transient data.
  • FastJSONAPI — A lightning fast JSON:API serializer for Ruby Objects.
  • Textacular — Textacular exposes full text search capabilities from PostgreSQL.
  • Rack::Attack — Rack middleware for blocking & throttling abusive requests.
  • Pagy — The ultimate pagination ruby gem.

To Do

Buy me a coffee

If you want to support me in server costs, consider buying me a coffee ! Thanks!

Spread The Voice

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/davidesantangelo/datoji . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License .


以上所述就是小编给大家介绍的《datoji - minimal JSON RESTful storage service.》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Writing Windows VxDs and Device Drivers, Second Edition

Writing Windows VxDs and Device Drivers, Second Edition

Karen Hazzah / CMP / 1996-01-12 / USD 54.95

Software developer and author Karen Hazzah expands her original treatise on device drivers in the second edition of "Writing Windows VxDs and Device Drivers." The book and companion disk include the a......一起来看看 《Writing Windows VxDs and Device Drivers, Second Edition》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试