surrealpatch/docs/ENDPOINTS.md

62 lines
1.6 KiB
Markdown
Raw Normal View History

2016-02-26 22:28:02 +00:00
# Endpoints
This document describes RESTful http endpoints which can be used to query and manipulate the database.
---
### SQL
2016-04-04 09:07:56 +00:00
The SQL endpoint allows you to query the database using any SQL query supported by Surreal. The content body must contain the properly formatted SQL queries which should be executed by the database. It may include a batch of SQL statements separated by a semicolon.
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `POST` `https://api.surreal.io/sql`
2016-02-26 22:28:02 +00:00
---
2016-04-04 09:07:56 +00:00
### Key Value
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
The key value endpoints allow you to manipulate the database records without needing to use SQL. It only includes a small portion of the functionality available with SQL queries. The endpoints enable you to use the database as if it were an API, using multi-tenancy separation, and multi-level authentication for preventing access to specific data within a database.
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `GET` `https://api.surreal.io/key/{table}`
```sql
SELECT * FROM {table}
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `POST` `https://api.surreal.io/key/{table}`
```sql
CREATE {table}
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `DELETE` `https://api.surreal.io/key/{table}`
```sql
DELETE {table}
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `GET` `https://api.surreal.io/key/{table}/{key}`
```sql
SELECT * FROM @{table}:{id}
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `PUT` `https://api.surreal.io/key/{table}/{key}`
```sql
UPDATE @{table}:{id} CONTENT {} RETURN AFTER
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `POST` `https://api.surreal.io/key/{table}/{key}`
```sql
CREATE @{table}:{id} CONTENT {} RETURN AFTER
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `PATCH` `https://api.surreal.io/key/{table}/{key}`
```sql
MODIFY @{table}:{id} DIFF {} RETURN AFTER
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `TRACE` `https://api.surreal.io/key/{table}/{key}`
```sql
SELECT HISTORY FROM @{table}:{id}
```
2016-02-26 22:28:02 +00:00
2016-04-04 09:07:56 +00:00
- `DELETE` `https://api.surreal.io/key/{table}/{key}`
```sql
DELETE @{table}:{id}
```