Generate Test Data with Postman and Random Key
Postman’s collection radically simplifies random data generation
Coming up with test data sets in your API development that resemble customers’ personal information but are completely fictional may sound like a couple of days worth of work. If you use Postman, the same requirement can be fulfilled within minutes.
A new collection shipped with Postman, called Random Data API pulls together 16 endpoints (as of the moment of writing), i.e. 16 classes of data that will respond to your calls with strings of personal information: realistic-looking, yet fictional. The services included cover the basics such as numbers, date and time (within the specified domain) and more tricky and domain-specific information, like Social Security Numbers, Credit Card Numbers, National Insurance Numbers, and regionalised (on a per country basis) location and names.
You can import the collection from your Postman client:
- Click on the “New” button to import the collection.
2. Navigate to the API Network tab.
3. Type “random”. The API provider will pop up in the results. Open the thumbnail and select to run the API.
4. Random Data API will show on the Collections tab.
5. You need to register before using the API. For a start, Random Key assigns you 10,000 free requests that you can use to play around with the API.
Select the “Register” POST request. The request’s URL, headers and body are pre-filled.
6. Substitute the sample email with your email address and hit “Send”.
7. Check your Inbox for a welcome email from Random Key. The email will include your authorization token that you can use to validate the requests.
8. Copy the authorization key and set it as a global variable in Postman. Use a key that will help you distinguish the token from other apps in use. “auth” is chosen as a default auto-filled value within all collection.
9. The variable can now be used in all subsequent requests. Choose the “Quota” GET method to test drive your account. If your token is saved as something other than “auth”, update the Headers section. Otherwise hit send directly.
If all went as expected, you should be able to see the number of requests left to use. You can monitor the number of allocated requests by calling the Quota endpoint at any time of your testing (it does not cost a request).
10. Try Social Security Number with the default settings (or update the value associated with the auth key, if customized).
SSN numbers supported by Random Key follow the SSA specification for a valid SSN format.
11. Try the Location endpoint to generate a random location in the US.
The location set published by Random Key includes all incorporated locations in the US as per the latest census.
12. Consult the Postman documentation for more information about the API.
13. Check the Random Key’s website for more information about the API and other services, such as Test Data API.
Let us know in the comments if your tests were successful!