Git Product home page Git Product logo

jsonbox's Introduction

jsonbox.io

A HTTP based JSON storage. It lets you store, read & modify JSON data over HTTP APIs for FREE. Ideal for small projects, prototypes or hackathons, where you don't have to spin up your own data store.

API Documentation

Base URL: https://jsonbox.io/

Create

You can create a record (or add a record) to a box by using HTTP post to jsonbox.io/${BOX_ID}.

curl -X POST 'https://jsonbox.io/demobox_6d9e326c183fde7b' \
    -H 'content-type: application/json' \
    -d '{"name": "Jon Snow", "age": 25}'

Response:

{"_id":"5d776a25fd6d3d6cb1d45c51","name":"Jon Snow","age":25,"_createdOn":"2019-09-10T09:17:25.607Z"}

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

curl -X POST 'https://jsonbox.io/demobox_6d9e326c183fde7b' \
    -H 'content-type: application/json' \
    -d '[{"name": "Daenerys Targaryen", "age": 25}, {"name": "Arya Stark", "age": 16}]'
[
  {"_id":"5d776b75fd6d3d6cb1d45c52","name":"Daenerys Targaryen","age":25,"_createdOn":"2019-09-10T09:23:01.105Z"},
  {"_id":"5d776b75fd6d3d6cb1d45c53","name":"Arya Stark","age":16,"_createdOn":"2019-09-10T09:23:01.105Z"}
]

You can also pass in an optional collections parameter in the URL to group records jsonbox.io/${BOX_ID}/${COLLECTION}.

Note: A valid ${BOX_ID} & ${COLLECTION} should contain only alphanumeric characters & _. ${BOX_ID} should be atleast 20 character long.

Read

Use HTTP GET to read all the records or a single record. You can also query & sort the records.

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b'
[
  {"_id":"5d776b75fd6d3d6cb1d45c52","name":"Daenerys Targaryen","age":25,"_createdOn":"2019-09-10T09:23:01.105Z"},
  {"_id":"5d776b75fd6d3d6cb1d45c53","name":"Arya Stark","age":16,"_createdOn":"2019-09-10T09:23:01.105Z"},
  {"_id":"5d776a25fd6d3d6cb1d45c51","name":"Jon Snow","age":25,"_createdOn":"2019-09-10T09:17:25.607Z"}
]

To get all records inside a collection Sample collection name: "users":

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b/users'

To sort the records by a specific field use sort query param. In the below example the output will be sorted in the descending order of the age.

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b?sort=-age'

To read a specific record use jsonbox.io/${BOX_ID}/${RECORD_ID}.

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b/5d776a25fd6d3d6cb1d45c51'

To query records, you have to pass the key & value as shown below.

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b?q=name:arya%20stark'

All the accepted query params are as follows.

Param Description Default
sort Used to sort the result set by the specific field. Add a prefix "-" to sort in reverse order. -_createdOn
skip Used to skip certain no. of fields. Can be used for pagination. 0
limit Used to limit the results to a specific count. Can be used for pagination. Max. is 1000. 20
q Query for filtering values. Check out the format below.

Filtering

You can pass a filter in a query by passing them in URL param q as shown below:

curl -X GET 'https://jsonbox.io/demobox_6d9e326c183fde7b?q=name:arya%20stark,age:>13'

The above sample will look for the name arya stark and age greater than 13. You can filter on Number, String & Boolean values only.

Different filters for Numeric values.

Sample
To filter values greater than or less than a specific value q=age:>10 or q=age:<10
To filter values greater (or less) than or equal to a specific value q=age:>=10 or q=age:<=10
To filter values that match a specific value. q=age:=10

Different filters for String values.

Sample
Filter values that start with a specific string q=name:arya*
Filter values that end with a specific string q=name:*stark
Filter values where a specific string appears anywhere in a string q=name:*ya*
Filter values that match a specific string q=name:arya%20stark

You can combine multiple fields by separating them with commas as shown below:

https://jsonbox.io/demobox_6d9e326c183fde7b?q=name:arya%20stark,age:>13,isalive:true

Update

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

curl -X PUT 'https://jsonbox.io/demobox_6d9e326c183fde7b/5d776b75fd6d3d6cb1d45c53' \
    -H 'content-type: application/json' \
    -d '{"name": "Arya Stark", "age": 18}'

Delete

Use HTTP DELETE to delete the record one by one.

curl -X DELETE 'https://jsonbox.io/demobox_6d9e326c183fde7b/5d776b75fd6d3d6cb1d45c53'

Limitations

Added some limitations to avoid abuse.

  1. The request body cannot be more than 100KB.
  2. Can't push or pull more than 1000 records at a time.
  3. There is no limit on the number of records you store in a box, but please don't abuse the API by storing large datasets of more than 5000 records. This is meant for small projects and that's why it is offered FREE of cost.

Wrappers

Note: The wrappers listed here are from other sources and it is not been tested on validated by us

Contribution

Any feedback, pull request or issue is welcome.

LICENSE

MIT

jsonbox's People

Contributors

0xflotus avatar bkerensa avatar freearhey avatar milovanderlinden avatar peteretelej avatar vasanthv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.