API
Version 1.0, 12-3-2008
CellDB will offer a light API: We will input and store the data, or output it.
In our current API, we don't process the data. Our philosopy is to leave that to the client. We will report all the data we have on a cell-id: clients can than use that to do whatever they want to calculate. In a later stage a more complex API might also offer these features.
Get Cell information
To get all information for one cell, you can do a GET call to:
http://celldb.org/api/?method=celldb.getcell
This accepts the following parameters:
Parameters:
- username=Your username for using the API. You can create an accout
- hash=Your hashcode for using the API, shown to you when you create an accout
- mcc=Mobile Country Code of the network. 3 digit INT. See Mobile_country_code for a list.
- mnc=Mobile Network Code of the network. See Mobile_network_code for a list.
- lac=Location Area Code of the cell.
- celllid= number of the cell
- format= Output format. Either xml/json/csv/text or debug. Defaults to xml.
The fields marked with
are mandatory.
This will return an response. For example, an XML response could look like this:
http://celldb.org/api/?method=celldb.getcell&username=celldb&hash=123456789&mcc=1&mnc=1&lac=1&cellid=1&format=xmlThis will return:
<?xml version="1.0" encoding="utf-8"?>
<result>
<cell>
<mcc>1</mcc>
<mnc>1</mnc>
<lac>1</lac>
<cellid>1</cellid>
<latitude>5.1</latitude>
<longitude>50</longitude>
<timestamp>1204903095</timestamp>
<type>received</type>
<signalstrength>47</signalstrength>
</cell>
<cell>
<mcc>1</mcc>
<mnc>1</mnc>
<lac>1</lac>
<cellid>1</cellid>
<latitude>5</latitude>
<longitude>50.1</longitude>
<timestamp>1204910989</timestamp>
<type>received</type>
<signalstrength>30</signalstrength>
</cell>
</result>
If multiple values are found for the query, all results are returned: The API leaves the calculations on the data to the application. If the API user that created this cell requests it, the enduserid is also returned
Add Cell information
Sending a single cell can be done with a GET request to http://celldb.org/api/?method=celldb.addcell with the folowing parameters:
Parameters:
- username=Your username for using the API. You can create an accout
- hash=Your hashcode for using the API, shown to you when you create an accout
- mcc=Mobile Country Code of the network. 3 digit INT. See Mobile_network_code for a list.
- mnc=Mobile Network Code of the network. See Mobile_network_code for a list.
- lac=Location Area Code of the cell.
- celllid= number of the cell
- latitude=the latitude where the cell was received.
- longitude=the longitude where the cell was received.
- timestamp=the timestamp the cell was received. INT, in UNIX time, seconds since 1 Jan 1970. Defaults to current timestamp of insertion.
- type=either 'received' or 'tower'. Defaults to 'received'.
- signalstrength= The strength of the received signal, if available, between 1 and 99. Defaults to 0, unknown for received cells, and 100 for tower cells.
- enduserid= A free text field, up to 100 chars, to identify the end user by the API user. Will only be returned to the API user that created the record. This can be used to see which user, within your application, created the point. Defaults to empty string.
- format= Output format. Either xml/json/debug. Defaults to xml.
The fields marked with
are mandatory.
Response:
The response depends on the output format (default XML).
For XML this will be:
<?xml version="1.0" encoding="utf-8"?>
<result>
<insert>OK</insert>
</result>
Or, in the case of an error, for example:
<?xml version="1.0" encoding="utf-8"?>
<result>
<error>
<code>401</code>
<desc>Username/hash does not match</desc>
</error>
</result>
Output Formats
All API calls have 5 output formats available: json, xml, csv, text or debug.
XML is default. Json is the same output in Json format. CSV is the output in coma seperated format, with each cell (for getcells) on a new line. text is csv without the comma\'s. Debug is mainly for debugging. text is mainly usefull for simple inserts: It returns "OK" if everything went well.
Error codes
The API can return several error codes. These are:
- 10 Username does not validate
- 20 HASH does not validate
- 100 MCC NOT VALID
- 110 MNC not valid
- 120 LAC not valid
- 130 CELLID not valid
- 140 Latitude not valid
- 150 Longitude not valid
- 401 Username/hash does not match
- 405 Non known method
- 404 Cell not found
- 500 DB ERROR
