All Projects → moharnadreza → Persianjsonplaceholder

moharnadreza / Persianjsonplaceholder

Licence: mit
Persian fake REST/GraphQL API for testing and prototyping.

Projects that are alternatives of or similar to Persianjsonplaceholder

Rest Api Examples
Test and Prototype with Fake Online REST/OAuth 2 APIs Examples
Stars: ✭ 13 (-88.18%)
Mutual labels:  rest, json, prototype
Json Serverless
Transform a JSON file into a serverless REST API in AWS cloud
Stars: ✭ 108 (-1.82%)
Mutual labels:  graphql, rest, json
Rest
☕ REST: Yoctoframework — https://rest.n2o.dev
Stars: ✭ 71 (-35.45%)
Mutual labels:  rest, json
Accounts
Fullstack authentication and accounts-management for Javascript.
Stars: ✭ 1,266 (+1050.91%)
Mutual labels:  graphql, rest
Restson Rust
Easy-to-use REST client for Rust programming language
Stars: ✭ 93 (-15.45%)
Mutual labels:  rest, json
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (+854.55%)
Mutual labels:  rest, json
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-51.82%)
Mutual labels:  rest, json
Behat Api Extension
API extension for Behat, used to ease testing of JSON-based APIs
Stars: ✭ 92 (-16.36%)
Mutual labels:  rest, json
Manifold
Manifold plugs into Java to supplement it with powerful features, from Type-safe Metaprogramming (direct access to GraphQL, JSON, XML, etc.), Extension Methods, Operator Overloading, and Unit Expressions to an integrated Template Engine and a Preprocessor. All fully supported in IntelliJ IDEA and Android Studio. Simply add Manifold to your project and begin taking advantage of it.
Stars: ✭ 993 (+802.73%)
Mutual labels:  graphql, json
Swagger Express Ts
Generate and serve swagger.json
Stars: ✭ 102 (-7.27%)
Mutual labels:  rest, json
Kaizen Openapi Editor
Eclipse Editor for the Swagger-OpenAPI Description Language
Stars: ✭ 97 (-11.82%)
Mutual labels:  rest, json
Flickr Sdk
Almost certainly the best Flickr API client in the world for node and the browser
Stars: ✭ 104 (-5.45%)
Mutual labels:  rest, 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 (-55.45%)
Mutual labels:  rest, json
Graphql Factory
A toolkit for building GraphQL
Stars: ✭ 44 (-60%)
Mutual labels:  graphql, json
Snug
Write reusable web API interactions
Stars: ✭ 108 (-1.82%)
Mutual labels:  graphql, rest
Dito
Dito.js is a declarative and modern web framework with a focus on API driven development, based on Objection.js, Koa.js and Vue.js – Released in 2018 under the MIT license, with support by Lineto.com
Stars: ✭ 44 (-60%)
Mutual labels:  rest, json
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (-16.36%)
Mutual labels:  rest, json
Strapi
🚀 Open source Node.js Headless CMS to easily build customisable APIs
Stars: ✭ 41,786 (+37887.27%)
Mutual labels:  graphql, rest
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+770%)
Mutual labels:  rest, json
Hyperpotamus
🥋 YAML/JSON automation scripting 🤺
Stars: ✭ 38 (-65.45%)
Mutual labels:  rest, json

PersianJSONPlaceholder

Persian JSONPlaceholder is a simple fake REST API for testing and prototyping.

Read this post on Virgool.io for more information about it.

Why?

Most of the time when trying a new library, hacking a prototype or following a tutorial, I found myself in need of some Persian data, So I decided to make Persian version of https://jsonplaceholder.typicode.com.

You can find it running here and are free to use it in your developments: https://jsonplaceholder.ir.

I hope you will find it useful.

Available resources

Let's start with resources, JSONPlaceholder provides the usual suspects:

How to

Here's some code using Fetch API showing what can be done with JSONPlaceholder.

Showing a resource

fetch('https://jsonplaceholder.ir/posts/1')
  .then(response => response.json())
  .then(json => console.log(json))

Listing resources

fetch('https://jsonplaceholder.ir/posts')
  .then(response => response.json())
  .then(json => console.log(json))

Creating a resource

// POST adds a random id to the object sent
fetch('https://jsonplaceholder.ir/posts', {
  method: 'POST',
  body: JSON.stringify({
    title: 'foo',
    body: 'bar',
    userId: 1,
  }),
  headers: {
    'Content-type': 'application/json; charset=UTF-8',
  },
})
  .then(response => response.json())
  .then(json => console.log(json))

/* will return
{
  id: 100,
  title: 'foo',
  body: 'bar',
  userId: 1
}
*/

Note: these resources will not be really created / updated or deleted on the server but it will be faked as if.

Updating a resource

fetch('https://jsonplaceholder.ir/posts/1', {
  method: 'PUT',
  body: JSON.stringify({
    id: 1,
    title: 'foo',
    body: 'bar',
    userId: 1,
  }),
  headers: {
    'Content-type': 'application/json; charset=UTF-8',
  },
})
  .then(response => response.json())
  .then(json => console.log(json))

/* will return
{
  id: 1,
  title: 'foo',
  body: 'bar',
  userId: 1
}
*/
fetch('https://jsonplaceholder.ir/posts/1', {
  method: 'PATCH',
  body: JSON.stringify({
    title: 'foo',
  }),
  headers: {
    'Content-type': 'application/json; charset=UTF-8',
  },
})
  .then(response => response.json())
  .then(json => console.log(json))

/* will return
{
  id: 1,
  title: 'foo',
  body: 'quia et suscipit [...]',
  userId: 1
}
*/

Deleting a resource

fetch('https://jsonplaceholder.ir/posts/1', {
  method: 'DELETE',
})

Filtering resources

Basic filtering is supported through query parameters.

// Will return all the posts that belong to the first user
fetch('https://jsonplaceholder.ir/posts?userId=1')
  .then(response => response.json())
  .then(json => console.log(json))

Nested resources

One level of nested route is available.

// equivalent to /comments?postId=1
fetch('https://jsonplaceholder.ir/posts/1/comments')
  .then(response => response.json())
  .then(json => console.log(json))

Here's the list of available nested routes:

Use JSONPlaceholder with GraphQL

All of the requests are available in https://jsonplaceholder.ir/graphql with different queries, get needed params for each one :)

// For example:get all data for one topic
let queryAllPosts = '{ posts { title body } }'
let queryAllComments = '{ comments { name email } }'
let queryAllAlbums = '{ albums { userId title } }'
let queryAllPhotos = '{ photos { title url } }'
let queryAllTodos = '{ todos { title completed } }'
let queryAllUsers = '{ users { username email } }'

// For example:get specific data by id
let queryOnePost = '{ post(id:2)  { title body } }'
let queryOneComment = '{ comment(id:3) { name email } }'
let queryOneAlbum = '{ album(id:4) { userId title } }'
let queryOnePhoto = '{ photo(id:5) { title url } }'
let queryOneTodo = '{ todo(id:6) { title completed } }'
let queryOneUser = '{ user(id:7) { username email } }'
// and ...

// Or use request package to fetch data as JSON file format
const request = require('request')

request(
  {
    method: 'POST',
    url: 'https://jsonplaceholder.ir/graphql',
    json: {
      query: queryOnePhoto,
    },
  },
  (err, res, data) => {
    console.log(data)
  }
)

// Fetch data as JSON file format
fetch('https://jsonplaceholder.ir/graphql', {
  method: 'POST',
  body: JSON.stringify(queryOneUser),
  headers: {
    'Content-type': 'application/json; charset=UTF-8',
  },
})
  .then(response => response.json())
  .then(json => console.log(json))
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].