The CARMA API provides REST-based access to data available on the CARMA site.
Use of the API does not require an API key, although CGD/CARMA reserves the right to limit or terminate access to the API at any time. If you make use of the API, we ask that you be polite and limit how often you make a direct call to the server and cache the result of API calls locally.
http://carma.org/api/1.1/method_name?param1=value[¶m2=value&format=xml]
API calls either return a JSON or XML string or an error message (Ex: Error: no matching plants.) This data can then be easily parsed and used to create widgets and/or mashups. PHP5 comes with the built-in function, json_decode, which converts JSON into an array.
Congressmen exist in the database as locations, because they represent a certain congressional district (location).
Let's start off by doing a search for James Moran using the searchLocations method.
This is a 2-step process. We first find the company ID from the searchCompanies method.
http://carma.org/api/1.1/searchCompanies?name=Dupont
When searching for the company Dupont, we will recieve a string of result data in JSON format.
Looking closely for the ID, and 5012 appears. Now use that ID in the searchPlants method.
http://carma.org/api/1.1/searchPlants?operating_company=5012
http://carma.org/api/1.1/searchLocations?name=Idaho
or to narrow by region_type (3=state):
http://carma.org/api/1.1/searchLocations?name=Idaho®ion_type=3
Looking at the JSON from example #4, Idaho has the location ID of 1211. Plug this into searchPlants and voila!
http://carma.org/api/1.1/searchLocations?name=Argentina®ion_type=2
Argentina's location ID is 15. Use that ID for the next call, also setting color=blue
http://carma.org/api/1.1/searchPlants?location=15&color=blue
![]() |
![]() |
![]() |
| Plant | Company | Region |
| Dirty | ![]() |
Clean |
| Lots of Energy |
![]() |
Little Energy |
CARMA is about equipping people with the best information. So if you've got a question, find an error, or just want to give us your reaction, we want to hear it.
CARMA is a product
of
The Center For
Global Development
All content © Copyright 2013
Center for Global Development.
All rights reserved | Credits