API Reference (beta)
The parsers.dev API is organized around REST with JSON request and responses and uses standard HTTP response codes.
The current API status is BETA. Minor changes are possible before leaving this status. After fixing the state, JSON-schemas will be published, with a description of the formats of requests and responses

Authentication

The parsers.dev API uses API key to authenticate requests. You can view and manage your API key in the parsers.dev Account Settings.
The parsers.dev APIs is a REST-based service. Subsequently, all requests to the APIs require this HTTP header:
1
x-api-key: Your parsers.dev API key
Copied!

Content type

The parsers.dev APIs is also a JSON-based service. You have to add Content-Type HTTP header to all your requests:
1
Content-Type: application/json
Copied!

URL and API versioning

Only one API version is operating at this time. Use this base URL for your requests:
https://api.parsers.dev/api/v1

Responses

All responses are JSON-based and follow one of these formats:
1
// successful response
2
{
3
"status": "OK",
4
"data": {...}
5
}
6
}
Copied!
1
// error response
2
{
3
"status": "ERROR",
4
"data": {
5
"code": <http-code>,
6
"message": "<error-message>",
7
"details": <mixed-object(optional)>,
8
}
9
}
Copied!
Http codes and error message you can find at Errors section
post
https://api.parsers.dev
/api/v1/parse/:dialect
Parse SQL (SQL β†’ AST)
Example:
JSON
JavaScript
Bash
1
{
2
"sql": "CREATE TABLE t(); SELECT 1; SELECT 1 FROM ; SELECT 2"
3
}
Copied!
1
const axios = require ('axios');
2
​
3
const api_key = '<your-api-key>';
4
​
5
const data = {
6
sql: 'CREATE TABLE t(); SELECT 1; SELECT 1 FROM ; SELECT 2',
7
};
8
​
9
axios({
10
method: 'POST',
11
headers: {
12
'Content-Type': 'application/json',
13
'x-api-key': api_key,
14
},
15
data,
16
url: `https://api.parsers.dev/api/v1/parse/postgresql/`,
17
}).then((response) => {
18
console.log(response.data);
19
})
20
.catch(function (error) {
21
console.error('api.parsers.dev error:');
22
console.error(JSON.stringify(error.response.data, null, 2));
23
});
24
​
Copied!
1
PARSERSDEV_API_KEY="<your-api-key>"; \
2
echo "{\"sql\": \"CREATE TABLE t(); SELECT 1; SELECT 2\"}" | \
3
curl \
4
--header "x-api-key: $PARSERSDEV_API_KEY" \
5
--header "Content-Type: application/json" \
6
--request POST --data @- https://api.parsers.dev/api/v1/parse/postgresql/
Copied!
post
https://api.parsers.dev
/api/v1/compile/:dialect
Compile SQL (SQL β†’ Special Object)
Example:
JSON
JavaScript
Bash
1
{
2
"ddl": "CREATE TABLE t (a int); CREATE",
3
"dmls": [
4
"table t; table t1",
5
"table",
6
"select * FROM t WHERE a = $1"
7
]
8
}
Copied!
1
const axios = require ('axios');
2
​
3
const api_key = '<your-api-key>';
4
​
5
const data = {
6
ddl: 'CREATE TABLE t (a int); CREATE',
7
dmls: [
8
'table t; table t1',
9
'table',
10
'select * FROM t WHERE a = $1'
11
]
12
};
13
​
14
axios({
15
method: 'POST',
16
headers: {
17
'Content-Type': 'application/json',
18
'x-api-key': api_key,
19
},
20
data,
21
url: `https://api.parsers.dev/api/v1/compile/postgresql/`,
22
}).then((response) => {
23
console.log(response.data);
24
})
25
.catch(function (error) {
26
console.error('api.parsers.dev error:');
27
console.error(JSON.stringify(error.response.data, null, 2));
28
});
29
​
Copied!
1
PARSERSDEV_API_KEY="<your-api-key>"; \
2
echo "{\"ddl\": \"CREATE TABLE t (a int); CREATE\", dml: [\"table t; table t1\", \"table\", \"select * FROM t WHERE a = $1\"]}" | \
3
curl \
4
--header "x-api-key: $PARSERSDEV_API_KEY" \
5
--header "Content-Type: application/json" \
6
--request POST --data @- https://api.parsers.dev/api/v1/compile/postgresql/
Copied!
post
https://api.parsers.dev
/api/v1/tools/snowflake/getddl-reorder
Snowflake GET_DDL function result reorder
​
Example:
JSON
JavaScript
Bash
1
{
2
"sql": "create view v1 as select * from t; create table t (a int);"
3
}
Copied!
1
const axios = require ('axios');
2
​
3
const api_key = '<your-api-key>';
4
​
5
const data = {
6
sql: 'create view v1 as select * from t; create table t (a int);'
7
};
8
​
9
axios({
10
method: 'POST',
11
headers: {
12
'Content-Type': 'application/json',
13
'x-api-key': api_key,
14
},
15
data,
16
url: `https://api.parsers.dev/api/v1/tools/snowflake/getddl-reorder`,
17
}).then((response) => {
18
console.log(response.data);
19
})
20
.catch(function (error) {
21
console.error('api.parsers.dev error:');
22
console.error(JSON.stringify(error.response.data, null, 2));
23
});
24
​
Copied!
1
PARSERSDEV_API_KEY="<your-api-key>"; \
2
echo "{\"sql\": \"Create view v1 as select * from t; create table t (a int);\"}" | \
3
curl \
4
--header "x-api-key: $PARSERSDEV_API_KEY" \
5
--header "Content-Type: application/json" \
6
--request POST --data @- https://api.parsers.dev/api/v1/tools/snowflake/getddl-reorder
Copied!
Last modified 6mo ago