Swallow
  • YOUR FIRST MODEL
    • Setting up your first project
    • Manual setup of a new product
    • Excel Model Upload
    • Create your team
    • Essential concepts
      • Syntax
      • Steps
      • Collections
      • Try Model
      • Spotlight
  • PROCESS
    • Team Management
    • Governance & Collaboration
  • BUILD
    • Building with AI
    • Step builder
      • Understanding step types
      • Ordering step blocks
      • Placeholder mode
      • Up/Downloading models
      • Sharing your model
      • Running tests
    • Inputs
    • Enriching Raw Data
      • Transform Data
      • Enrich via API
      • Data Set
      • Collection
      • Custom Code
    • Setting Up Decisions
      • Exclusions
      • Excesses
      • Endorsements
      • Refer
    • Making Calculations
      • Factors
      • Calculation
    • Outputs
  • TEST
    • Creating New Tests
    • Running Tests
    • Editing Tests
    • Reading & Interpreting Tests
    • Impact Testing
  • DATA
    • Working with real-time data
    • Data Views
    • Data Quotas
    • Troubleshooting
    • API Webhooks
    • Data Downloads
  • ADMIN & SETTINGS
    • Project Management
    • Account Management
  • INTEGRATIONS
    • Introduction
    • Payments
      • Stripe
      • GoCardless
      • Adyen
    • Alerting
      • Slack
      • Zapier
    • Data
      • AWS S3
      • Google Sheets
    • Admin
      • Socotra
      • Guidewire
      • Hubspot
      • Salesforce
  • Developer API
    • Introduction
    • Authentication
    • Errors codes
    • Endpoints
      • /quotes
      • /projects
      • /tests
      • /process
Powered by GitBook
On this page
  • 1. Connect to an API
  • 2. Test the API
  • 3. Store the returned variables in your model
  • Label
  • Output Key
  • Type
  • Expression
  • Default Value
  • 4. Save each variable
  • 5. Save the step
  1. BUILD
  2. Enriching Raw Data

Enrich via API

Using an API enrichment step in the builder to enrich raw data inputs with third-party APIs

PreviousTransform DataNextData Set

Last updated 1 year ago

Once you're confident that your input data is formatted correctly, you're ready to integrate APIs that you can hit in order to enrich your data.

How might you use the 'Integrate API' step?

If you were building a pricing model for car insurance, you may want to use third-party APIs to return information that a customer may not know or may not input accurately, or you may simply want to save them time by only requesting one datapoint which you can then enrich with many other variables from a trusted source.

For example, you may want to use the registration plate of a vehicle inputted by a customer to return the vehicle's make from the DVLA API.

1. Connect to an API

To get started, click the cog symbol in the top right of the 'Integrate API' step.

This guide assumes that a technical or development team has already set up a third-party API on your behalf.

For more information about how to set up an API, read our Developer API documentation.

  • Method - Here you can set the type of method you want to use to hit the API from the dropdown menu, choosing from three options:

    • 'GET'

    • 'POST'

    • 'PUT'

  • Timeout - Here you'll select your API timeout in milliseconds. e.g. 1000

  • URL - This will be the URL you've been supplied with to hit the API, and should have the 'Output Key' that you want to send to the API in the URL string, so that it will dynamically be added each time your model quotes. e.g. https://testapi.com/sw/enrich/dvla-vehicle/{{vehicle_reg_norm}}

  • Header Keys - This is where you'll populate the names of all header keys you've been given by the API provider.

  • Header Values - This is where you'll add the secret tokens you've been given from the API provider.

  • Data - This is where you enter the payload, and will likely be a blob of JSON. If you're unsure what should go here, consult your development or technical team - or the documentation for the third party API you're using.

You can click ‘Add Header’ at any time if you need to add additional rows of headers that may be required by the API, such as version credentials. These could be things like a username & password, additional tokens or API keys.

2. Test the API

Once you've connected with an API, you can test the endpoint to make sure it returns the data you're expecting in the timeframe you need it to.

This will also allow you to see what variables the API will provide you with in the response, which will be helpful when you build out your properties table in the next step.

3. Store the returned variables in your model

The last step is storing all of the variables you want to use from the API response for future use in your model.

For every variable you want to save, simply click the 'Add' button at the top right of the table to begin the process, and complete the fields below.

Label

This labels the new variable you're saving. Keep the description short and simple so you can recognise it easily in future steps.

Output Key

This is output name that will be passed to the next step, and how you'll reference the input in any syntax in future steps.

This will be auto-generated based on the label you've given, but you can edit it at any time.

Type

This the data type of the data you want to transform the input into.

You can choose from 5 data types: Boolean, Decimal, Integer, String or Date.

Expression

To store the variable in its raw format with no transformation, simply write the expression in brackets, with the variable as it is named in the API response between curly brackets - e.g. ({{make}}).

To do some simple transformation of the data, check out our full page on Syntax. Here you can learn how to structure your expression in more detail, debug and see a full glossary.

Default Value

This is the default value you want to set.

This is the data the model will default to if the value is not defined by the customer or the transformation fails for any reason.

4. Save each variable

Once you're happy with the settings of the variable you're adding, just press the 'Save' button in the bottom right of the modal and you're ready to add more variables to the table if you want to.

5. Save the step

Once you're happy with all of your variables, just press the 'Save' button in the top right of the screen. You're now ready to head back to the 'Build' screen.

Once you've added the 'Integrate API' step and named it, like you will with any other step in the Build tool (), you'll need to add the API settings and secret keys for whichever third-party API you're using.

If you don't want to store the variables in their raw format, you can do some simple transformation of that data using Swallow to reformat it the way you want.

more on that here
Syntax
The Integrate API step
'Test Endpoint' button
Viewing the code of a successful API response
ADD button for new variables
Save variable button
Save step button