Accessing Enipedia Power Plant Dataset Reconciliation API via POST requests

From Enipedia
Jump to: navigation, search

Note: This work has been superseded by that of Elasticsearch on Enipedia

[edit] Background

See Enipedia Power Plant Dataset Reconciliation API. This page demonstrates how you can communicate with the reconciliation API by sending POST requests.

[edit] Single Query Mode

Given this json data:

{
   "query":"Amercoeur 1 R Ccgt",
   "properties":[
      {
         "pid":"Country",
         "v":"Belgium"
      }
   ]
}

Send a request with curl:

curl -d 'query={"query" : "Amercoeur 1 R Ccgt","properties" : [{ "pid" : "Country", "v" : "Belgium" }]}' http://enipedia.tudelft.nl/matching/reconcile.php

which returns:

{
   "result":[
      {
         "id":"http://enipedia.tudelft.nl/wiki/Amercoeur_Powerplant",
         "name":"name:Amercoeur Powerplant|owner:electrabel sa|city:roux",
         "type":[
            {
               "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
               "name":"Powerplant"
            }
         ],
         "score":1.05948,
         "latitude":50.43,
         "longitude":4.38,
         "match":false
      },
      {
         "id":"http://enipedia.tudelft.nl/wiki/Amel_Powerplant",
         "name":"name:Amel Powerplant|owner:renogen sa|city:amel",
         "type":[
            {
               "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
               "name":"Powerplant"
            }
         ],
         "score":0.765584,
         "latitude":50.35,
         "longitude":6.15,
         "match":false
      }
   ]
}

[edit] Multiple Query Mode

Given this data:

{
   "q0":{
      "query":"Flevo 4",
      "type":"Category:Powerplant",
      "type_strict":"should",
      "properties":[
         {
            "pid":"Country",
            "v":"Netherlands"
         }
      ]
   },
   "q1":{
      "query":"Gelderland 13",
      "type":"Category:Powerplant",
      "type_strict":"should",
      "properties":[
         {
            "pid":"Country",
            "v":"Netherlands"
         }
      ]
   }
}

Send a request with curl. You need to specify --header "Expect:" due to the proxy server.

curl --header "Expect:" -d 'queries={"q0":{"query":"Flevo 4","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Netherlands"}]},"q1":{"query":"Gelderland 13","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Netherlands"}]},"q2":{"query":"Dinorwig 4","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"United Kingdom"}]},"q3":{"query":"Eems 6","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Netherlands"}]},"q4":{"query":"Ruien 3","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Belgium"}]},"q5":{"query":"Awirs 5","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Belgium"}]},"q6":{"query":"Dinorwig 5","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"United Kingdom"}]},"q7":{"query":"Polaniec 3","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Poland"}]},"q8":{"query":"Ruien 4","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"Belgium"}]},"q9":{"query":"Ffestiniog 1","type":"Category:Powerplant","type_strict":"should","properties":[{"pid":"Country","v":"United Kingdom"}]}}' http://enipedia.tudelft.nl/matching/reconcile.php

"type" and "type_string" are not needed - these are based on the Google Refine Reconciliation API specification, but are not used internally.

You should get something like this:

{
   "q0":{
      "result":[
         {
            "id":"http://enipedia.tudelft.nl/wiki/Floriade_Powerplant",
            "name":"name:Floriade Powerplant|owner:nuon n v|city:haarlemmemeer",
            "type":[
               {
                  "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
                  "name":"Powerplant"
               }
            ],
            "score":0.725394,
            "latitude":52.3,
            "longitude":4.7,
            "match":false
         },
         {
            "id":"http://enipedia.tudelft.nl/wiki/Gevudo_Wte_Powerplant",
            "name":"name:Gevudo Wte Powerplant|owner:gevudo afvalverwerking n v|city:dordrecht",
            "type":[
               {
                  "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
                  "name":"Powerplant"
               }
            ],
            "score":0.722383,
            "latitude":51.8,
            "longitude":4.67,
            "match":false
         }
      ]
   },
   "q1":{
      "result":[
         {
            "id":"http://enipedia.tudelft.nl/wiki/Gelderland_Powerplant",
            "name":"name:Gelderland Powerplant|owner:electrabel nederland|city:nijmegen",
            "type":[
               {
                  "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
                  "name":"Powerplant"
               }
            ],
            "score":1.32346,
            "latitude":51.8554,
            "longitude":5.83039,
            "match":false
         },
         {
            "id":"http://enipedia.tudelft.nl/wiki/Geldermalsen_Powerplant",
            "name":"name:Geldermalsen Powerplant|owner:nuon n v|city:geldermalsen",
            "type":[
               {
                  "id":"http://enipedia.tudelft.nl/wiki/Category:Powerplant",
                  "name":"Powerplant"
               }
            ],
            "score":1.01996,
            "latitude":51.89,
            "longitude":5.3,
            "match":false
         }
     ]
   }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Portals
Advanced
Toolbox