API Index

User's Total Meters

get a users total meters to date

uri:

http://c2logapi.appspot.com/api/1/user/totalmeters

method:

GET

status codes:

200: ok
401: invalid Concept 2 Online logbook user name or password
403: invalid or missing C2 Logbook REST API key
503: throttled

Examples:


Python using httplib2

    import base64
    import httplib2
    import simplejson
    url = "http://powertwenty.com/c2logapi/1/user/totalmeters"
    h = httplib2.Http()
    authorizationHeader = "Basic %s"%base64.b64encode("%s:%s"%("username", "password"))
    resp, content = h.request( url, "GET", headers={ "Authorization":authorizationHeader, "X-API-KEY":"xxxxxxx" } )
    assert resp["status"]=="200"
    totalmeters = int(simplejson.loads(content))
    print totalmeters


Python using RestKit

from restkit import RestClient, httpc
transport = httpc.HttpClient()
transport.add_authorization(httpc.BasicAuth(("username", "password")))
client = RestClient(transport=transport)                                                       
totalMeters = int(client.get("http://powertwenty.com/c2logapi/1/user/totalmeters", headers={"X-API-Key":"xxxxxxxxxxxxxxx"}))
print totalMeters 


Java

import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;

public class GetTotalMeters {

    public static void main(String[] args) throws Exception {

        final String userName = "user";
        final String password = "password";

        Authenticator.setDefault(new Authenticator()
        {
            protected PasswordAuthentication getPasswordAuthentication()
            {
                return new PasswordAuthentication(userName, password.toCharArray());
            }
        }
        );

        URL totalMetersUri = new URL("http://powertwenty.com/c2logapi/1/user/totalmeters");
        HttpURLConnection connection = (HttpURLConnection) totalMetersUri.openConnection();
        connection.setRequestProperty("X-API-KEY", "xxxxxxxxxxxxxxx");
        connection.connect();
        assert connection.getResponseCode()==200 : String.format("http error reported: %d",connection.getResponseCode());
        BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));       
        int usersTotalMeters = Integer.parseInt(rd.readLine());
        System.out.printf("total meters = %d", usersTotalMeters);
    }
}

 
 
Copyright © 2006-2015 by Power Twenty, LLC. All Rights Reserved.
Design by Interspire