Try the REST API Using a REST Client

Ever wanted to work with our REST API without the need to install the PowerShell or Python toolkits? Take the REST API for a test drive using a REST client.

Try the REST API Using a REST Client

Summary

Check the guide to using the Pure Storage REST API with modern tools like Postman and cURL, incorporating updated authentication methods, expanded API endpoints, and best practices for efficient storage management and automation.

image_pdfimage_print

There are several options for REST clients that can be used just do a Google search (oh wait I meant Bing). For this post I am using the Advanced Rest Client Application within Chrome (sorry IE).

REST

The best place to get started is to review the REST API documentation that is available from the FlashArray web management interface or from our Community.

To get started open up the Advanced REST client and you will see essentially a blank template.

Using the DNS name or the IP address of your FlashArray we need to start by retrieving an API Token for a specific user. For this example we will use our default management account pureuser. Using the REST API documentation Authentication section as a reference the API call to use is POST https://myarray/api/1.4/auth/apitoken with a defined Payload. As you will notice from the documentation the Payload required for retrieving an API Token is:

The below screenshot maps out step-by-step the different options to enter and select to retrieve the API Token for the pureuser account. Step 4 is very important to set the Content-Type to application/json as all of our return results are in JSON format.

Once Step 5 Send has been clicked the FlashArray will respond with output directly back to the Advanced REST client as show below.

REST

Note: The Purity Operating Environment introduced the REST API 1.0 with version 3.4.3. Depending on the version currently running on the FlashArray you may encounter the below error. The examples in this article use REST API 1.4 but if you do encounter this error you can use the URL https://myarray/api/api_version which will show all the supported versions of the REST API for that particular FlashArray. For example on my array it returns {“version”: [“1.0”, “1.1”, “1.2”, “1.3”, “1.4”]}. If you try this same URL in Internet Explorer a .json package will be downloaded with the same details.

Now we have an API Token and can create a session to the FlashArray. Using the API Token we pass that using the POST https://myarray/api/1.4/auth/session with the api_token variable as the Payload. See the below screenshot. The api_token in the Payload was taken from the previous step above. These tokens will be unique for every FlashArray and every API Token defined user.

REST

After sending the above request making sure to set POST and Content-Type to application/json we will get the following.

Now we have established a session with the FlashArray and can begin retrieving some information. Let’s get all the volumes that are currently created on this FlashArray using GET https://myarray/api/1.4/volume and click Send.

REST

The results will be a list of all the volumes as show in the below screenshot.

One final thing to do is to create a new volume called BLOG-DEMO. Using the very same REST API call from above we just add the name of the volume we want to create to the end, then define the Size as the Payload.

REST

Hit Send and a new volume will be created and the successful results shown.

This was a quick primer on how to use any REST client to work with our REST API directly. Using the documentation as reference you can work perform any of the API calls just make sure you have an authenticated session.

Updated Practices for Using the Pure Storage REST API with Modern Tools

Since the original publication of this blog, Pure Storage has introduced enhancements to its REST API and provided support for modern tools, making it easier than ever to interact with FlashArray and Pure1 APIs. Below are updated practices for leveraging the Pure Storage REST API with modern clients:

1. Authentication Updates

  • API Token Authentication: The latest versions of the FlashArray REST API and Pure1® REST API use API tokens for authentication, providing enhanced security.
  • How to Generate a Token:
    1. Log in to the FlashArray management interface.
    2. Navigate to Settings > API Token.
    3. Generate a new token and save it securely.
  • Use this token in your REST client by including it as a header:jsonCopyEdit{ "Authorization": "Bearer <your-api-token>" }

2. Expanded API Endpoints

  • The FlashArray REST API now includes a broader range of endpoints for managing volumes, snapshots, and performance metrics.
  • The Pure1® REST API offers endpoints for monitoring, analytics, and capacity planning across all connected arrays.

3. Using Modern REST Clients

  • Postman:
    • Postman is now the recommended tool for exploring and testing the Pure Storage REST APIs.
    • Import pre-built API collections for FlashArray or Pure1 directly into Postman to get started quickly. Download the collections from the Pure Storage GitHub repository.
  • cURL:
    • For scripting and quick testing, cURL remains a reliable choice. Example:bashCopyEditcurl -X GET "https://<flasharray-url>/api/1.18/volume" \ -H "Authorization: Bearer <your-api-token>"

4. Automation with SDKs

  • Pure Storage now offers SDKs for Python, PowerShell, and other languages, allowing developers to automate tasks programmatically.
  • Example with Python SDK:pythonCopyEditfrom purity_fb import PurityFb array = PurityFb("flasharray-url") array.login("your-api-token") volumes = array.volumes.list_volumes() print(volumes)

5. Best Practices

  • Secure Your API Tokens: Always store API tokens in a secure location and never hard-code them into scripts.
  • Use Rate Limiting: Be mindful of API rate limits when designing automation or integration workflows.
  • Monitor API Usage: Track API interactions through Pure1® or FlashArray logs for better visibility and troubleshooting.

6. Additional Resources

By adopting these modern tools and practices, you can streamline your interaction with the Pure Storage REST API and leverage the latest features for efficient storage management and automation.

Banner CTA - Real-World Data Virtualization Stories eBook