Skip to Content
[CAIDA - Center for Applied Internet Data Analysis logo]
Center for Applied Internet Data Analysis
www.caida.org > projects : spoofer : data-api.xml
Spoofer Data API
This page documents the Spoofer Data API.

Overview

The CAIDA Spoofer Data API provides a public data interface to the publicly shareable data collected by the Spoofer service.

Data API URL

Users can request data via the URL: https://api.spoofer.caida.org/ whose home page provides information on endpoint syntax and data model.

Endpoints

  • GET /sessions Retrieves the collection of Session resources
  • GET /sessions/{id} Retrieves a Session resource.

Rules of Usage

These are the rules for the usage of the data API:

  • CAIDA places no limit on the amount of requests, however, we ask that you send a message to spoofer-info at caida dot org if you plan to regularly do more than 1000 requests/day.
  • The CAIDA Master Acceptable Use Agreement (AUA) terms and conditions apply.

Data Model

The data model contains a unique integer identifier for each session with a timestamp and parameters for read access, the IPv4 client address, the IPv6 client address, the country, NAT4 address, NAT6 address, and information about private and routed addresses. The API allows the user to query based on date, sessionid, or by Autonomous System Number (ASN). The API returns a paginated list of measurement sessions.

Try out the API in your browser

If you point your browser at https://api.spoofer.caida.org you will see the Spoofer API 1.0.0 documentation. To expand the documentation for each endpoint, click the GET buttons. Once expanded, each endpoint displays the example parameters with buttons to "Try it out." The try it out button provides a graphical interface that allows the user to build and execute queries to the Spoofer API and see the example responses.

Example Script

We offer an example script, implemented in PERL, that programmatically queries the Spoofer Data API.

The script takes command line arguments to query by date or sessionid with an optional Autonomous System Number (ASN). The script assumes the local system has the curl data transfer tool installed as well as the JSON::XS and Getopt::Long; PERL packages. At runtime, the script collects its command-line arguments and builds a query for the Spoofer Data API.

The API returns a list of sessions one page (30 lines) at a time. The example script decodes each line of JSON and prints the page numbers (to STDERR so as not to send redirected results output to file) preceding each page of results received.

The curl command makes use of the '-s' (silent) mode as well as '-X' switch to specify a custom GET command-line.

The following example execution of the dump-spoofer-api-after.pl script returns all public Spoofer measurement sessions after May 1, 2020. perl dump-spoofer-api-after.pl --date "1 May 2020"

The Spoofer Data API platform core provides native support for pagination in the collection results it returns. Each page contains 30 items per page by default. The code chunk below (lines 69-101 of the example script) displays the heart of the script, a while () loop, that handles the paginated results returned by the Spoofer Data API. The script determines the type of query and command arguments; either target sessionid, ASN, or time range and constructs the appropriate command-line to send to the Spoofer Data API. The while loop below processes the results returned by the GET request to the API as a collection of objects.

while(1)
{
    print STDERR "page $page\n";

    my $obj;
    open(CURL, "$cmd |") or die "could not curl";
    while(<CURL>)
    {
        chomp;
        $obj = decode_json($_);
    }
    close CURL;
    last if(!defined($obj));
  
    foreach my $member (@{$obj->{"hydra:member"}})
    {
        my $str = encode_json($member);
        print "$str\n";
    }
  
    if(defined($obj->{"hydra:view"}) &&
        defined($obj->{"hydra:view"}{"hydra:next"}))
    {
        my $next = $obj->{"hydra:view"}{"hydra:next"};
        $cmd = "curl -s -X GET \"$api$next\" -H \"$accept\"";
    }
    else
    {
        last;
    }
    $page++;
}

Example response records:


     {"client6":"2001:16b8:5700::/40","privatespoof":"blocked","@id":"/sessions/884935","@type":"Session","session":884935,"client4":"82.207.238.0/24","privatespoof6":"blocked","timestamp":"2020-04-27T00:09:45-07:00","nat6":false,"asn4":"8881","nat4":true,"asn6":"8881","routedspoof":"blocked","routedspoof6":"blocked","country":"deu"}
     {"routedspoof6":"blocked","routedspoof":"rewritten","country":"ind","privatespoof6":"blocked","timestamp":"2020-04-27T00:14:50-07:00","nat6":false,"asn4":"45609","asn6":"45609","nat4":true,"@id":"/sessions/884936","@type":"Session","session":884936,"client4":"223.181.219.0/24","client6":"2401:4900:4a00::/40","privatespoof":"rewritten"}
     {"client4":"103.236.179.0/24","session":884937,"@id":"/sessions/884937","@type":"Session","privatespoof":"received","client6":null,"country":"phl","routedspoof":"received","routedspoof6":null,"nat4":false,"asn6":null,"nat6":null,"asn4":"135607","timestamp":"2020-04-27T00:15:49-07:00","privatespoof6":null}
     {"country":"fra","routedspoof":"unknown","routedspoof6":"unknown","nat4":true,"asn6":"42473","asn4":"42473","nat6":true,"timestamp":"2020-04-27T00:19:14-07:00","privatespoof6":"unknown","client4":"37.252.225.0/24","session":884939,"@type":"Session","@id":"/sessions/884939","privatespoof":"unknown","client6":"2a00:11c0::/40"}



  Last Modified: Tue Jul-28-2020 14:29:13 UTC
  Page URL: https://www.caida.org/projects/spoofer/data-api.xml