By it’s nature, an API does not have a user interface. But you may want to use some kind of UI to play around with various options when making an API Test. There’s a great tool out there called Postman which can be used to help you create an API Test. For this example we’re going to play with the NASA Open API.
We can use Postman to help us make the call to the Neo REST API and get a list of asteroids that are on the closest approach to Earth. This is a basic GET call with 3 parameters for the start and end dates and an API Key. You can register for an API Key with NASA, for this example we will use the DEMO_KEY key which is significantly rate limited. If you fill in the URL and Params, then hit Send it should look like this:
Now we have made an API call and can see the results very clearly. In Postman click the Code button (on the right side below the Parameters). In the pop-up window select NodeJS Request and copy this to the clipboard.
The only difference you need in order to use this code in Synthetics is that New Relic uses the $http syntax instead of having to require the request library. So you can comment out the first line and change the request() method to say $http() instead. You can now Validate and should see the response:
This is handy if you have a bunch of parameters or perhaps need to test a POST call with a form or a file or other values. You can try them quickly with Postman and once your call is working right you can export the code quickly into New Relic. Good luck!