Getting Started with Postman

Page content

Introduction

It can be helpful for learning an API to access via a tool such as Postman in order to explore the endpoints and understand how it all works. In this guide, you will learn how to get the entire suite of Lex Machina API endpoints configured and running with automatic authentication. The goal is to accomplish this in five minutes or less.

Pre-requisites

You need to have created an application and noted the client_id and client_secret as per these directions. You also need Postman available, either in the browser app or a desktop version.

Step One - Import Via OpenAPI

Navigate to the Lex Machina API docs and you will see on the right a button labeled “View Raw”.

This button opens a dialog which gives you two options - to either copy the OpenAPI spec to the clipboard or download it locally. For most import tools, either option is supported. These directions assume you downloaded the file.

In Postman you have the ability to import APIs. The button is in the upper left in the desktop app. After you click, it will ask you to provide the file. Drag-and-drop or navigate to the spec file that you just downloaded.

After you accept, Postman will parse the file and create all the endpoints that exist in the API. The full suite of endpoints is now set up but you can’t use it yet. For that you will need the next step, configuring authentication.

Step Two - Configuring Authentication

Now you will set up authentication. By doing it at the collection level, you can configure once and have it work for every endpoint in the API.

First, open the menu for the collection and choose the Edit option. This will let you set up options for the entirety of the collection.

Once open, click the Authorization tab. You will be presented options on how to get and use the authorization tokens. If these options were not selected by default, the key ones you need to configure are:

  • Type: OAuth 2.0
  • Add auth data to: Request Headers
  • Grant Type: Client Credentials
  • Client Authentication: Send as Basic Auth header

Give your token a name that is meaningful to you. Use the previously recorded Client ID and Client Secret in their respective fields. For the Access Token URL field use https://api.lexmachina.com/oauth/client_credential/accesstoken

After filling all that out, click the Get New Access Token button. If all the values were filled out properly you will see a value in the access token field on the upper right. Click Update to save your configuration. At this point, your collection now has authorization configured at the collection level. Click Update to save this configuration.

Step Three - Take It For A Ride

With authorization ready, it should now be available to all the endpoints you previously imported. To test this out, try one of the endpoints that does not take any input. Any of the endpoints that begin the “List” are good for that.

No Parameter Requests

Click the List Courts endpoint in the left panel (or whatever you prefer). On the upper right click the Send button, which will then show you the results in JSON format below.

Path or Query Parameter Requests

For GET requests that have parameters, the procedure is slightly different. When you open the endpoint there will be a Params tab. Underneath that you will find the parameters set up. Enter in the Value field what you want to use, and then click Send. You will see the results for that particular input.

POST Requests

For POST requests such as the one that queries district cases, the procedure is different. The parameters will be included in the body of the request. When you first open the Body tab of one of these requests, you will see every possible option available by default. This will mostly be a process of sculpting away the unused options.

Note that on all of the date criteria, they need to be in ISO 8601 format, which is “YYYY-MM-DD”.

Once you have crafted the body down into a set of criteria that you are happy with, click Send and you will see the results. Note that it is in the form of Lex Machina case IDs. These can then be passed back into the /district-cases/{case_id} endpoint to look up the information about that case.

This should get you started exploring the API and understanding its capabilities. If you need any help, feel free to reach out at dslusher@lexmachina.com. Happy exploring!