How can we help?

    API Overview

    Follow

    Introduction

    The Club OS API uses HTTPS URLs to access its services.  

    1. Here is a good article on REST concepts if you are not familiar.   
    2. You should also understand the JSON data format as all request data must be sent as valid JSON

    Authentication

    Club OS will provide you a username and password when you register for the API.  Here is a good reference for HTTP Basic Auth, which you must use for all requests.

    You must also make sure to specify the Content-Type header to be "application/json" or your request will not succeed.

    UNIX Timestamp

    Unless otherwise specified, all DateTimes that are sent and received from the Club OS webservices will be in standard UNIX Timestamp format, as shown below.

    yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

    Response

    The Club OS API will respond to requests with a generic JSON Response object.

    Property
    Type
    Description
    status Boolean true if the request was successful, false if errors.
    responses ResponseMessage[] An array of ResponseMessage objects (see below).

    ResponseMessage

    Property
    Type
    Description
    message String A message describing what happened to the resource.
    value String The id of the resource.
    Using the ResponseMessage value property

    The value property will contain the Club OS unique id for the resource you are creating or updating.

    Below is an example ResponseObject:

    {"status": true, "responses": [{"message":"Member Found","value":"CLUBOSUSERID"}]}

    After a successful request, you should save this value in your database with the associated user.  Then you can use them on subsequent requests.  The unique id's ensure that our systems stay in-sync throughout the existence of the resource you are dealing with (users, memberships, club services, and payments).  

    Examples

    Feel free to use any library or language you wish.  If you would like to share your code once it works, please email support@club-os.com and they will post it here.

    PHP

    This example shows how to post a prospect to Club OS via PHP (Wordpress, Facebook, etc..)

     

         
        $body = array(
            'firstName' => $first_name,
            'lastName' => $last_name,
            'email' => $email,
            'mobilePhone' => $mobile_phone,
            'notes' => $notes,
            'source' => $source,
            'gender' => 'M'
        ); 
        $body_json = json_encode($body);
     
        $args = array(
            'headers' => array(
                   'Authorization' => 'Basic ' . base64_encode( '[username]' . ':' . '[password]' ),
                   'Content-type' => 'application/json'
            ),
            'body' => $body_json,
            'sslverify' => false
        );
      
        $resp = wp_remote_post( $post_url, $args );

     

     

    JAVA

    This example uses the Jersey library which can be downloaded here.

    public class JerseyClientTest {
             
            Client client = Client.create();
     
            client.addFilter(new HTTPBasicAuthFilter(username, password)); //Provided by Club OS
     
            WebResource webResource = client
     
               .resource("https://api.club-os.com/users");
     
            MultivaluedMap<String, String> params = new MultivaluedMapImpl();
     
            params.add("clubLocationId", clubLocationId); //Provided by Club OS
     
            ClientResponse response = webResource.queryParams(params).type("application/json")
     
               .post(ClientResponse.class, requestBody);
     
            String output = response.getEntity(String.class);
    }

    PERL

    #!/usr/bin/perl -w
    #
    # Sample starter Perl code for Club OS integration.
    use strict;
    use JSON::XS;
    use REST::Client;
    use MIME::Base64;
    my $locationID = 'xxx'; # provided by Club OS
    my $auth = MIME::Base64::encode_base64( 'username:password' ); # provided by Club OS
    my $client = REST::Client->new();
    $client->addHeader( 'Content-type' => "application/json" );
    $client->addHeader( 'Authorization' => "Basic $auth" );
    $client->GET( $res );
    my $response = JSON::XS->new->allow_nonref->decode( $client->responseContent() );
    print "Status: $response->{status}\n";
    foreach my $response_message ( @{ $response->{responses} } ) {
       print "Message: $response_message->{message}\n" if $response_message->{message};
       print "Value: $response_message->{value}\n" if $response_message->{value};
    }
    # sample POST
    # my $json = JSON::XS->new->allow_nonref->encode( {
    #       role => 'member',
    #       firstName => 'Bob',
    #       lastName => 'Gonzalez',
    #       # etc...
    #    } );
    # $client->POST( $res, $json );
    # my $response = JSON::XS->new->allow_nonref->decode( $client->responseContent() );
    exit();

     

     

    Was this article helpful?
    0 out of 1 found this helpful

    Comments