https://github.com/zekrotja/example-rest-api
An open demo REST API to build demos on, test stuff against or just play around with.
https://github.com/zekrotja/example-rest-api
demo-api example example-api example-rest-api rest rest-api rust vercel
Last synced: about 2 months ago
JSON representation
An open demo REST API to build demos on, test stuff against or just play around with.
- Host: GitHub
- URL: https://github.com/zekrotja/example-rest-api
- Owner: zekroTJA
- License: mit
- Created: 2023-05-12T00:46:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-29T13:52:59.000Z (12 months ago)
- Last Synced: 2025-04-02T17:53:29.784Z (about 2 months ago)
- Topics: demo-api, example, example-api, example-rest-api, rest, rest-api, rust, vercel
- Language: Rust
- Homepage: https://example-rest-api.vercel.app
- Size: 43.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example REST API
An open source CRUD REST API to build demos on, test stuff against or just play around with.
## Motivation
For other projects, I was using [restful-api.dev](https://restful-api.dev/) to build demos or tests on. But recently, this page proved to be somewhat inconsistent and unreliable, so I wanted to build something hosted on [Vercel](https://vercel.com) using [Upstash](https://upstash.com/) as Redis Store, so that it should be a pretty reliable alternative.
## API Documentation
The live API root endpoint is as following.
```
https://example-rest-api.vercel.app
```The API accepts request payloads as `application/json` and responses are encoded in `application/json`.
> **Warning**
> Created objects are **not persistent nor protected**. Objects are usually automatically removed 24 hours after creation or modification. Objects and collection are not proof against modification by unauthorized individuals.### Objects
#### `Collection`
```ts
type CollectionRequest = {
name: string;
};type CollectionResponse = {
id: string;
created_at: string; // Format: RFC3339
name: string;
};
```#### `Object`
```ts
type ObjectRequest = {
name: string;
data: { [key: string]: any };
};type ObjectResponse = {
id: string;
created_at: string; // Format: RFC3339
name: string;
data: { [key: string]: any };
};
```### Endpoints
#### Create Collection
Create a new collection.
```
POST /api/collections
```##### Request Payload
```ts
CollectionRequest
```*Example:*
```json
{
"name": "my games"
}
```##### Response Payload
```ts
CollectionResponse
```*Example:*
```json
{
"id": "chf13ur2iejc717547r0",
"created_at": "2023-05-12T10:16:27.319442753+00:00",
"name": "my games"
}
```#### Get Collection
Retrieve information about a collection by ID.
```
GET /api/collections/:collectionid
```##### Response Payload
```ts
CollectionResponse
```*Example:*
```json
{
"id": "chf13ur2iejc717547r0",
"created_at": "2023-05-12T10:16:27.319442753+00:00",
"name": "my games"
}
```#### Update Collection
Update a collection.
```
POST /api/collections/:collectionid
```##### Request Payload
```ts
CollectionRequest
```*Example:*
```json
{
"name": "My Games"
}
```##### Response Payload
```ts
CollectionResponse
```*Example:*
```json
{
"id": "chf13ur2iejc717547r0",
"created_at": "2023-05-12T10:16:27.319442753+00:00",
"name": "My Games"
}
```#### Delete Collection
Delete a collection by ID.
```
DELETE /api/collections/:collectionid
```#### Create Object
Create a new object in a collection.
```
POST /api/collections/:collectionid/objects
```##### Request Payload
```ts
ObjectRequest
```*Example:*
```json
{
"name": "Cyberpunk 2077",
"data": {
"publisher": "CD PROJECT RED",
"developer": "CD PROJECT RED",
"released": "2020-12-10T00:00:00Z",
"tags": ["Cyberpunk", "Open World", "RPG", "Sci-fi"],
"age_rating": "18"
}
}
```##### Response Payload
```ts
ObjectResponse
```*Example:*
```json
{
"id": "chf15eacaqvs715h7ae0",
"created_at": "2023-05-12T10:19:37.971387217+00:00",
"name": "Cyberpunk 2077",
"data": {
"tags": [
"Cyberpunk",
"Open World",
"RPG",
"Sci-fi"
],
"age_rating": "18",
"publisher": "CD PROJECT RED",
"developer": "CD PROJECT RED",
"released": "2020-12-10T00:00:00Z"
}
}
```#### Get Object
Retrieve an object from a collection by ID.
```
GET /api/collections/:collectionid/objects/:objectid
```##### Response Payload
```ts
ObjectResponse
```*Example:*
```json
{
"id": "chf15eacaqvs715h7ae0",
"created_at": "2023-05-12T10:19:37.971387217+00:00",
"name": "Cyberpunk 2077",
"data": {
"tags": [
"Cyberpunk",
"Open World",
"RPG",
"Sci-fi"
],
"age_rating": "18",
"publisher": "CD PROJECT RED",
"developer": "CD PROJECT RED",
"released": "2020-12-10T00:00:00Z"
}
}
```#### Update Object
Update an object in a collection.
```
POST /api/collections/:collectionid/objects/:objectid
```##### Request Payload
```ts
ObjectRequest
```*Example:*
```json
{
"name": "Cyberpunk 2077",
"data": {
"publisher": "CD PROJECT RED",
"developer": "CD PROJECT RED",
"released": "2020-12-10T00:00:00Z",
"tags": ["Cyberpunk", "Open World", "RPG", "Sci-fi", "Explicit"],
"age_rating": "18"
}
}
```#### Delete Object
Delete an object in a collection by ID.
```
DELETE /api/collections/:collectionid/objects/:objectid
```---
© 2023 Ringo Hoffmann.
Covered by the [MIT License](LICENSE).