Latest Neocron News and Information
- New test server patch #563 has been released to Vedeena
Difference between revisions of "THNapi:Items DB - JSON Examples"
From Neocron Wiki
(Deprecation warning about using the items slug) |
(Use syntaxhighlight) |
||
Line 1: | Line 1: | ||
== List of groups of datasets you have access to == | == List of groups of datasets you have access to == | ||
− | < | + | <syntaxhighlight lang="json"> |
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/api/access-list.json | curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/api/access-list.json | ||
− | </ | + | </syntaxhighlight> |
=== Response === | === Response === | ||
− | < | + | <syntaxhighlight lang="json"> |
{ | { | ||
"deny": [], // For THN use only | "deny": [], // For THN use only | ||
Line 28: | Line 28: | ||
] | ] | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
== API Response for a group == | == API Response for a group == | ||
− | < | + | <syntaxhighlight lang="json"> |
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/weapons/melee.json | curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/weapons/melee.json | ||
− | </ | + | </syntaxhighlight> |
=== Response === | === Response === | ||
− | < | + | <syntaxhighlight lang="json"> |
{ | { | ||
"groups": { | "groups": { | ||
Line 135: | Line 135: | ||
}, | }, | ||
... // Rest of JSON response cut for clarity | ... // Rest of JSON response cut for clarity | ||
− | </ | + | </syntaxhighlight> |
== API Response for an Item == | == API Response for an Item == | ||
− | < | + | <syntaxhighlight lang="json"> |
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/1562.json | curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/1562.json | ||
− | </ | + | </syntaxhighlight> |
..or you can use the item slug. | ..or you can use the item slug. | ||
'''Warning:''' Using a Item slug is deprecated and will be removed in V3.2.0 of the Items DB. | '''Warning:''' Using a Item slug is deprecated and will be removed in V3.2.0 of the Items DB. | ||
− | < | + | <syntaxhighlight lang="json"> |
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/mendicant-rifle.json | curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/mendicant-rifle.json | ||
− | </ | + | </syntaxhighlight> |
=== Response === | === Response === | ||
− | < | + | <syntaxhighlight lang="json"> |
{ | { | ||
"groups": { | "groups": { | ||
Line 263: | Line 263: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
== Note on redirects == | == Note on redirects == | ||
You will note the '''-L''' option in the Curl examples. This is due to the Items DB redirecting to the required language (English and German currently supported) so https://db.techhaven.org/weapons/melee.json will redirect to https://db.techhaven.org/en/weapons/melee.json This redirect behaviour will be changed in V3.2.0 of the Items DB. | You will note the '''-L''' option in the Curl examples. This is due to the Items DB redirecting to the required language (English and German currently supported) so https://db.techhaven.org/weapons/melee.json will redirect to https://db.techhaven.org/en/weapons/melee.json This redirect behaviour will be changed in V3.2.0 of the Items DB. |
Revision as of 13:02, 29 July 2020
List of groups of datasets you have access to
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/api/access-list.json
Response
{
"deny": [], // For THN use only
"granted": [
{
"name": "Rifles",
"path": "weapons/rifles",
"granted": true
},
{
"name": "Helmets",
"path": "armor/helmets",
"granted": true
},
{
"name": "Brain implants",
"path": "implants/brain",
"granted": true
},
... // Rest of output skipped for clarity.
]
}
API Response for a group
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/weapons/melee.json
Response
{
"groups": {
"65": {
"id": 65,
"groupPath": "weapons/melee/lowtech",
"name": "Lowtech Melee Weapon",
"shortName": "Lowtech Melee Weapon",
"description": "A weapon requiring the Melee Combat (M-C) Skill."
},
"76": {
"id": 76,
"groupPath": "weapons/melee/hightech",
"name": "Hightech Melee Weapon",
"shortName": "Hightech Melee Weapon",
"description": "A weapon requiring the Melee Combat (M-C) and Hightech Combat (T-C) Skills."
}
},
"items": [
{
"id": 1265,
"visible": true,
"pendingUpdates": false,
"slug": "stiletto",
"name": "Stiletto",
"shortName": null,
"level": 2,
"patch": 176,
"version": 2,
"added": {
"date": "2006-10-28 12:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated": {
"date": "2007-04-09 12:34:56.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"detail": {
"2": {
"parentVersion": 1,
"weight": "0.35",
"text": null,
"name": "Stiletto",
"shortName": null,
"level": 2,
"patch": 176,
"version": 2,
"added": {
"date": "2007-04-09 12:34:56.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated": {
"date": "2007-04-09 12:34:56.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"status": "Imported",
"image": {
"x": 64,
"y": 32,
"cdn_url": "https://cdn.techhaven.org/xxxxxxxxxxxxxxxxxxxxx.png", // Only visible to API users with access
"filename": "xxxxxxxxxxxxxxxxxxxxx.png" // Only visible to API users with access
},
"attribute": [ // Not all attributes will be available to API users
{
"name": "Strength",
"shortName": "STR",
"attributeGroup": "Main Skills",
"attributeType": "requirement",
"value": "1.00",
"formatValue": 1
},
{
"name": "This item is researchable",
"shortName": "Researchable",
"attributeGroup": "Item information",
"attributeType": "tag",
"value": "1.00",
"formatValue": "Enabled"
},
{
"name": "This item can be purchased from a shop vendor",
"shortName": "Purchasable",
"attributeGroup": "Item procurement",
"attributeType": "tag",
"value": "1.00",
"formatValue": "Enabled"
}
],
"groupReference": 65
}
},
"url": "https://db.techhaven.org/item/stiletto",
"url_json": "https://db.techhaven.org/item/1265.json"
},
... // Rest of JSON response cut for clarity
API Response for an Item
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/1562.json
..or you can use the item slug.
Warning: Using a Item slug is deprecated and will be removed in V3.2.0 of the Items DB.
curl -i -H "X-THN-API-User: <Your API user Key>" -H "X-THN-API-Key: <Your API key secret>" -H "Accept: application/json" -H "Content-Type: application/json" -L https://db.techhaven.org/item/mendicant-rifle.json
Response
{
"groups": {
"63": {
"id": 63,
"groupPath": "weapons/rifles/lowtech",
"name": "Lowtech Rifle",
"shortName": "Lowtech Rifle",
"description": "A weapon requiring the Rifle Combat (R-C) Skill."
}
},
"item": {
"parentVersion": null,
"weight": "3.65",
"text": null,
"name": "Mendicant Rifle",
"shortName": null,
"level": 6,
"patch": 176,
"version": 1,
"added": {
"date": "2006-01-31 11:56:53.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated": {
"date": "2006-01-31 11:56:53.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"image": {
"x": 96,
"y": 64,
"cdn_url": "https://cdn.techhaven.org/xxxxxxxxxxxxxxxxxxxxxxx.png",
"filename": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.png"
},
"linkItem": [ // Not available to all API users
{
"id": 1256,
"name": "Tangent Weaponpart 3",
"linkType": "part",
"quantity": 1
},
{
"id": 1258,
"name": "Tangent Weaponpart 5",
"linkType": "part",
"quantity": 1
},
{
"id": 1019,
"name": "Tangent Weaponpart 2",
"linkType": "part",
"quantity": 1
},
{
"id": 396,
"name": "Metal Plate",
"linkType": "recycle",
"quantity": 3
},
{
"id": 418,
"name": "Wire Junk",
"linkType": "recycle",
"quantity": 3
},
{
"id": 395,
"name": "Metal Pipes",
"linkType": "recycle",
"quantity": 1
}
],
"status": "Imported",
"attribute": [
{
"name": "Dexterity",
"shortName": "DEX",
"attributeGroup": "Main Skills",
"attributeType": "requirement",
"value": "6.00",
"formatValue": 6
},
{
"name": "Rifle combat",
"shortName": "R-C",
"attributeGroup": "Dexterity",
"attributeType": "requirement",
"value": "15.00",
"formatValue": 15
},
{
"name": "This item is researchable",
"shortName": "Researchable",
"attributeGroup": "Item information",
"attributeType": "tag",
"value": "1.00",
"formatValue": "Enabled"
},
{
"name": "Weapon Type",
"shortName": "Weapon Type",
"attributeGroup": "Weapon information",
"attributeType": "tag",
"value": "45.00",
"formatValue": "Assault Rifle"
}
],
"groupReference": 63,
"id": 1562
}
}
Note on redirects
You will note the -L option in the Curl examples. This is due to the Items DB redirecting to the required language (English and German currently supported) so https://db.techhaven.org/weapons/melee.json will redirect to https://db.techhaven.org/en/weapons/melee.json This redirect behaviour will be changed in V3.2.0 of the Items DB.