REST API for developers

January 05, 2012 • Administrator       
Synopsis

The CensorNet Hosted Web Security platform provides a web services REST API for developers to integrate the service into their own applications.

Article

The CensorNet Hosted Web Security platform provides a web services REST API for developers to integrate the service into their own applications. It can also be used to create maintenance programs, such as being able to automatically import users into your account from an external source (e.g. LDAP, RADIUS, PostgreSQL, MySQL, etc) or export reporting data for processing elsewhere. As the API is RESTful, it supports the standard HTTP methods of GET, POST, PUT and DELETE. All message payloads use JSON format for lightweight communication. As it is based on HTTP, the API can be used from any programming language that provides access to the HTTP protocol (e.g. Perl, PHP, C#, C, etc).

Any feature or option that you see in the Hosted Web Security web control panel can be accessed via the API. That's powerful!

 

Example uses of the API

 

  • Create your own web filtering applications on your platform of choice
  • Integrate the service into your own application / portal
  • Develop your own Graphical User Interface for our Hosted Web Security service
  • Automatic provisioning of customer and user accounts
  • Export users from an external data source and import into your Hosted Web Security account
  • Synchronise custom URL lists with internal / external applications (e.g. Intranet)
  • ....plus much more

 

Example usage

The following simplified example is given in Perl but the same principal applies to other programming languages. It shows how to authenticate your script with the API which allows you to retrieve a secret key that is then used to securely sign future requests to our API.

 

    #!/usr/bin/perl

    use MIME::Base64;
    use LWP 5.64;

    $auth_header = "$username:$password"; // Valid admin user credentials

    $base64_auth_header = "Basic " . encode_base64($auth_header);
    $url = "https://www.cloudwebfiltering.com/api/auth";

    my $browser = LWP::UserAgent->new;

    my @send_headers = (

        'Authorization' => $base64_auth_header,
        );

    print "Authenticating...";
    $response = $browser->get($url, @send_headers);

    if($response->is_success) { # We got a 200 OK from the server

        print "Success\n";
   }

 

To access the REST API you will need to obtain the REST API developer documentation from your account manager which is available to all customers at no extra cost.

Related articles


Last modified on Mon, January 09, 2012 « Back