• Stars
    star
    225
  • Rank 177,187 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.

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://localhost:3000. 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://localhost:3000/packs/{PACK_ID}/entries?page=1>; rel="first", <https://localhost:3000/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://localhost:3000/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://localhost:3000/packs' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'
    

Body

{
  "entries": [
    { 
      "entry": 
        {
          "name": "Davide Santangelo", 
          "role": "Senior Team Lead" 
        } 
    }
  ]
}

result

{
  "data": {
    "id": "918f6a68-89f7-4f0c-aa6d-73b447d92819",
    "type": "pack",
    "attributes": {
      "entries_count": 0,
      "created_at": "2020-06-11T14:22:12.354Z",
      "updated_at": "2020-06-11T14:22:12.354Z"
    }
  }
}

Read

curl -X GET 'https://localhost:3000/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://localhost:3000/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://localhost:3000/packs/{PACK_ID}' -H 'content-type: application/json' -H 'Authorization: Token {KEY}'
    

CRUD ENTRY

Create

curl -X POST 'https://localhost:3000/{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://localhost:3000/{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://localhost:3000/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://localhost:3000/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://localhost:3000/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://localhost:3000/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://localhost:3000/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

  • Bulk Insert
  • GraphQL
  • Webhook

Buy me a coffee

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

Spread The Voice

Tweet

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.

More Repositories

1

dato.rss

The best RSS Search experience you can find
Ruby
624
star
2

api.rss

RSS as RESTful. This service allows you to transform RSS feed into an awesome API.
Ruby
345
star
3

webinspector

Ruby gem to inspect completely a web page. It scrapes a given URL, and returns you its meta, links, images more.
Ruby
290
star
4

searq.org

SearQ, the RSS search engine that is both speedy and free! SearQ offers a RESTful API that simplifies the search for data from RSS feeds. Finding what you need has never been easier with SearQ.
Ruby
94
star
5

api.rss.ui

Simple search interface around FeediRSS API.
JavaScript
51
star
6

tuns

Twitter Unfollower Notification Service. Keep track when someone unfollow you on Twitter.
Ruby
44
star
7

emailhunter

A tiny Ruby wrapper around Hunter (former EmailHunter) API (https://hunter.io/)
Ruby
41
star
8

restcountry

This is a Ruby wrapper library around the API provided by REST Countries http://restcountries.eu
Ruby
34
star
9

geoplugin

This is a Ruby wrapper library around the API provided by Geoplugin (http://www.geoplugin.com).
Ruby
9
star
10

secrypto

simple API for encrypt/decrypt text
Ruby
9
star
11

github-search-react

Simple fetching data from GitHub API with react and axios.
JavaScript
9
star
12

gameoflife

This is a Rails implementation of "Conway's Game of Life." Conway's game is a mathematical simulation where cells live or die based on certain rules.
Ruby
8
star
13

gemsbot

Telegram Bot wrapper for the RubyGems.org API
Ruby
7
star
14

github-vue-card

Vue.js + GitHub REST API + Tailwind CSS
Vue
6
star
15

scrappet-rest-api

rails app for web scraping purposes. It scrapes a given page (by the URL), and returns you all informations about that page.
Ruby
6
star
16

curl-gems

A basic cURL wrapper around RubyGems.org API
Ruby
4
star
17

text_search

TextSearch allows to count the number of occurrences of a word in a text.
Ruby
3
star
18

hnow

A new and alternative interface to Hacker News
Ruby
3
star
19

geopweb

Just a little demo of the geoplugin ruby gem
Ruby
3
star
20

apiwha

A tiny ruby wrapper around apiwha whatsapp API (https://apiwha.com)
Ruby
2
star
21

bibliotech

RESTful library management API
Ruby
1
star