Logo
New RPC users get 35% off their first monthView the offer
Infura
Infura8 min read

Infura IPFS: A Practical Guide to Decentralized Storage

Infura IPFS provides a managed gateway to the InterPlanetary File System, simplifying decentralized storage for developers. This guide explains how to get started, use the API, and follow best practices.

TL;DR

Infura IPFS is a service that offers HTTP-based access to the IPFS network, allowing developers to add, pin, and retrieve content without running their own IPFS nodes. This guide covers the essentials: creating an account, obtaining API keys, using the REST API, and following best practices for reliable decentralized storage.

What is Infura IPFS?

Infura IPFS is a managed service that provides HTTP endpoints for interacting with the InterPlanetary File System (IPFS). It abstracts away the complexity of running and maintaining IPFS nodes, offering developers a simple way to store and retrieve content on IPFS.

The service is part of Infura's suite of Web3 infrastructure tools, which also include Ethereum and other blockchain RPC endpoints. Infura IPFS supports common IPFS operations such as adding files, pinning content, and retrieving data via a gateway.

  • Managed IPFS nodes: No need to run your own IPFS daemon.
  • HTTP API: Interact with IPFS using standard REST calls.
  • Pinning service: Keep important content available on the network.
  • Gateway access: Retrieve content via a dedicated HTTP gateway.

Getting Started with Infura IPFS

To use Infura IPFS, you need an Infura account. Sign up at infura.io and create a new project. Once your project is created, you will receive a project ID and a project secret, which are used for authentication.

Infura IPFS uses HTTP Basic Authentication. Include your project ID as the username and your project secret as the password in the Authorization header of your requests.

  • Create an account at infura.io.
  • Create a new project in the Infura dashboard.
  • Note your project ID and project secret.
  • Use these credentials for API authentication.
# Example: Set environment variables for authentication
export INFURA_IPFS_PROJECT_ID="your-project-id"
export INFURA_IPFS_PROJECT_SECRET="your-project-secret"

Infura IPFS API Endpoints

Infura IPFS exposes an HTTP API that mirrors the IPFS Core API. The base URL for the API is https://ipfs.infura.io:5001. All requests must include the authentication header.

Common endpoints include /api/v0/add for adding files, /api/v0/pin/add for pinning content, and /api/v0/cat for retrieving content. The gateway for retrieving content via HTTP is https://infura-ipfs.io/ipfs/.

# Example: Add a file using curl
curl -X POST -u "$INFURA_IPFS_PROJECT_ID:$INFURA_IPFS_PROJECT_SECRET" \
  "https://ipfs.infura.io:5001/api/v0/add" \
  -F file=@myfile.txt

Authentication and Security

Infura IPFS requires authentication for all API calls. Use HTTP Basic Auth with your project ID and project secret. Never expose your project secret in client-side code or public repositories.

For added security, consider restricting your project's access to specific IP addresses or using environment variables to store credentials. Infura also allows you to rotate your project secret if needed.

  • Use HTTP Basic Auth with project ID and secret.
  • Store credentials securely, e.g., in environment variables.
  • Avoid embedding secrets in frontend code.
  • Rotate secrets periodically or if compromised.

Pinning and Content Availability

Pinning is crucial for ensuring that content remains available on IPFS. When you add a file via Infura IPFS, it is automatically pinned to Infura's nodes, but you can also pin existing content by its CID.

Keep in mind that pinning does not guarantee permanent availability; it depends on the service's policies and the underlying IPFS network. For long-term persistence, consider additional pinning services or redundant storage.

  • Files added via Infura IPFS are pinned by default.
  • Use the pin/add endpoint to pin existing CIDs.
  • Monitor your pinned content and storage usage.
  • Consider multiple pinning services for redundancy.

Best Practices for Using Infura IPFS

To get the most out of Infura IPFS, follow best practices for performance and reliability. Structure your requests efficiently, handle errors gracefully, and be mindful of rate limits.

Infura IPFS may impose rate limits or usage quotas depending on your plan. Check the Infura documentation for current limits and consider implementing retry logic with exponential backoff for transient errors.

  • Batch operations where possible to reduce request overhead.
  • Implement error handling and retries for network issues.
  • Cache frequently accessed content locally.
  • Review Infura's usage policies and limits regularly.

Common Use Cases

Infura IPFS is used in a variety of Web3 applications, from storing NFT metadata to hosting decentralized websites. Its HTTP API makes it accessible from any programming language or platform.

Developers often use Infura IPFS to store JSON data for smart contracts, images for NFTs, or entire static sites. The service integrates well with other Infura products, such as Ethereum RPC endpoints.

  • NFT metadata and asset storage
  • Decentralized website hosting
  • Document and file sharing
  • Backup and archival of blockchain data

Troubleshooting and Support

If you encounter issues with Infura IPFS, check the Infura status page for service outages. Common problems include authentication errors, rate limiting, and network timeouts.

For authentication errors, verify your project ID and secret. For rate limiting, review your usage and consider upgrading your plan if needed. Infura provides documentation and support channels for further assistance.

  • Verify credentials if receiving 401 errors.
  • Check rate limits if experiencing 429 errors.
  • Consult Infura documentation for API details.
  • Contact Infura support for persistent issues.

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started