BIN Data Integration Guides

Use the following integration options to interact with Pagos BIN Data using common tools:

cURL

The most basic way to interact with the Pagos BIN Data service is via the Command Line Interface (CLI). To start, you'll need the following:

Next, confirm cURL is installed in your terminal application.

curl --version

You should see output similar to below. The version itself isn’t important for our service at this time.

super-computer ~ % curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets

To receive the JSON data for a BIN, make a request using your API key and the desired BIN number:

curl -H "x-api-key: [your API key]"  "[https://parrot.prod.pagosapi.com/bins?bin=[BIN/IIN number]"

Google Sheets

The following example shows how you can pull in BIN data to Google Sheets by leveraging Brad Jasper's work with the ImportJSON App Script code library. To start, you'll need the following:

  • A Pagos API Key: You'll use this when you send a request for data to Pagos
  • The BIN Data API endpoint: https://parrot.prod.pagosapi.com/bins
  • A Google account so you can create a new Google Sheet
  • A tab open to the ImportJSON Github site—specifically the ImportJSON.gs script. For this example we’re using version 1.6.0 / June 2, 2019.

Step 1: Set up a Google Sheet and Apps Script Project

Create both a new Google Sheet and Google Apps Script project:

  1. Create a new Google Sheet and title it (e.g. Pagos BIN Data).
  2. Click Extensions, then click Apps Script to open a new Apps Script project.
  3. Name your project (e.g. Pagos BINs)
  4. Next to Files, click +, then select Script from the drop-down menu. This will create a new Apps Script file, titled Untitled.gs. We recommend renaming this file ImportJSON before hitting enter.

Step 2: Add ImportJSON

Next, add the ImportJSON library to your new Google Apps Script project. With other languages and integrations you probably use git to pull code down to your machine to work with a library; since this is basically scripting, however, you'll “install” the library using cut and paste:

  1. In the tab where you have the ImportJSON.gs Githup repository open, click Raw to access the raw code.
  2. Copy all the code into your clipboard.
  3. Return to your Google Apps Script project. Delete all the content of your ImportJSON.js file, then paste all the text from your clipboard.
  4. Click save.

Step 3: Add a Helper Function

We've created a wrapper function that makes it easy to drop in your API key and get started with Pagos BIN Data:

  1. In your Google Apps Script project, click Code.gs, then select all of the existing text and hit Delete.
  2. Copy in the below text and paste it into Code.gs, then save your project.
/**
 * Imports a Pagos Parrot JSON feed and returns the results to be inserted into a Google Spreadsheet. Uses the ImportJSON library.
 *
 * By default, data gets transformed so it looks more like a normal data import. Specifically:
 *
 * @param {url}          the URL to a public JSON feed
 * @param {query}        a comma-separated list of paths to import. Any path starting with one of these paths gets imported.
 * @param {parseOptions} a comma-separated list of options that alter processing of the data
 * @param {key}          a Pagos Parrot API Key
 * @customfunction
 *
 * @return a two-dimensional array containing the data, with the first row containing headers
 **/
function importParrotBINJSON(url, query, parseOptions, key) {
    var apikeyheader = {headers: {"x-api-key": key}};

    return ImportJSONAdvanced(url, apikeyheader, query, parseOptions, includeXPath_, defaultTransform_);
}

Step 4: Make Your First BIN Query

You can now close the Apps Script editor window or tab. To make your first BIN query:

  1. Go to cell A1 in your Google Sheet and type in an example BIN, such as 535316.
  2. Go to cell B1 and type in the function to call Pagos – note you need to replace the blue text (including brackets) with your API key:
=importParrotBINJSON("https://parrot.prod.pagosapi.com/bins?bin="&A1, ,"Headers", "[your API key]")

Analyze More Data

After you complete each of the steps above, you can begin pulling down card details, creating pivot tables, and analyzing data to your heart's content!

The ImportJSON library allows you to customize the output of the importParrotBINJSON call using the same options as ImportJSON. You can turn off headers and even customize the data you want. To get you started, we've pasted an additional example that removes the column headers (the noHeaders setting) and only returns the Network, Card Type, Card Product and Card Country:

=importParrotBINJSON("https://parrot.prod.pagosapi.com/bins?bin="&A1, "/card/product/product_name,/card/network,/card/type,/card/country/alpha2,/card/bank/name","noHeaders", "[your API key]")