NWDP डेटा API

कोड उदाहरण:

किसी भी क्षेत्र में "jones" होने वाले 5 परिणाम प्राप्त करें:
curl https://nwdp.nwic.in/hi/api/action/datastore_search \
  -H"Authorization:$API_TOKEN" -d '
{
  "resource_id": "35648095-54a2-4a87-9fc3-1e437cf9179b",
  "limit": 5,
  "q": "jones"
}'
const resp = await fetch(`https://nwdp.nwic.in/hi/api/action/datastore_search`, {
    method: 'POST',
    headers: {
        'content-type': 'application/json',
        authorization: API_TOKEN
    },
    body: JSON.stringify({
        resource_id: '35648095-54a2-4a87-9fc3-1e437cf9179b',
        limit: 5,
        q: 'jones'
    })
})
await resp.json()
$json = @'
{
  "resource_id": "35648095-54a2-4a87-9fc3-1e437cf9179b",
  "limit": 5,
  "q": "jones"
}
'@
$response = Invoke-RestMethod https://nwdp.nwic.in/hi/api/action/datastore_search`
  -Method Post -Body $json -Headers @{"Authorization"="$API_TOKEN"}
$response.result.records

(using the ckanapi क्लाइंट लाइब्रेरी)

from ckanapi import RemoteCKAN

rc = RemoteCKAN('https://nwdp.nwic.in/hi/', apikey=API_TOKEN)
result = rc.action.datastore_search(
    resource_id="35648095-54a2-4a87-9fc3-1e437cf9179b",
    limit=5,
    q="jones",
)
print(result['records'])
library(httr2)

req <- request("https://nwdp.nwic.in/hi/api/action/datastore_search")
result <- req %>% 
    req_headers(Authorization = API_TOKEN) %>% 
    req_body_json(list(
        resource_id = '35648095-54a2-4a87-9fc3-1e437cf9179b',
        limit = 5,
        q = 'jones'))
    req_perform %>% 
    resp_body_json
"watershed" या "survey" को विषय और "active" को इसके चरण के रूप में परिणाम प्राप्त करें:
curl https://nwdp.nwic.in/hi/api/action/datastore_search \
-H"Authorization:$API_TOKEN" -d '
{
"resource_id": "35648095-54a2-4a87-9fc3-1e437cf9179b",
  "filters": {
    "subject": ["watershed", "survey"],
    "stage": "active"
  }
}'
const resp = await fetch(`https://nwdp.nwic.in/hi/api/action/datastore_search`, {
    method: 'POST',
    headers: {
        'content-type': 'application/json',
        authorization: API_TOKEN
    },
    body: JSON.stringify({resource_id: '35648095-54a2-4a87-9fc3-1e437cf9179b', filters: {
        subject: ['watershed', 'survey'],
        stage: 'active'
    }})})
await resp.json()
$json = @'
{
  "resource_id": "35648095-54a2-4a87-9fc3-1e437cf9179b",
  "filters": {
    "subject": ["watershed", "survey"],
    "stage": "active"
  }
}
'@
$response = Invoke-RestMethod https://nwdp.nwic.in/hi/api/action/datastore_search`
  -Method Post -Body $json -Headers @{"Authorization"="$API_TOKEN"}
$response.result.records
from ckanapi import RemoteCKAN

rc = RemoteCKAN('https://nwdp.nwic.in/hi/', apikey=API_TOKEN)
result = rc.action.datastore_search(
    resource_id="35648095-54a2-4a87-9fc3-1e437cf9179b",
    filters={
      "subject": ["watershed", "survey"],
      "stage": "active",
    },
)
print(result['records'])
library(httr2)

req <- request("https://nwdp.nwic.in/hi/api/action/datastore_search")
result <- req %>% 
    req_headers(Authorization = API_TOKEN) %>% 
    req_body_json(list(
        resource_id='35648095-54a2-4a87-9fc3-1e437cf9179b', 
        filters = list(
            subject = list("watershed", "survey"), 
            stage = "active")))
    req_perform %>% 
    resp_body_json

कुछ API एपीआई एंडपॉइंट्स को GET क्वेरी स्ट्रिंग का उपयोग करके एक्सेस किया जा सकता है।

क्वेरी उदाहरण (पहले 5 परिणाम)

https://nwdp.nwic.in/hi/api/action/datastore_search?resource_id=35648095-54a2-4a87-9fc3-1e437cf9179b&limit=5

क्वेरी उदाहरण (परिणाम जो 'jones' शामिल करते हैं)

https://nwdp.nwic.in/hi/api/action/datastore_search?resource_id=35648095-54a2-4a87-9fc3-1e437cf9179b&q=jones