How to Get Companies with the Apollo API in PHP

by Endgrate Team 2024-07-26 4 min read

Apollo homepage

Introduction to Apollo API for Company Data

Apollo is a comprehensive sales intelligence and engagement platform that empowers businesses to streamline their sales processes. With a vast database of over 270 million contacts and 70 million companies, Apollo provides valuable insights and tools for sales teams to enhance their outreach and engagement strategies.

Integrating with Apollo's API allows developers to access rich company data, enabling them to enrich their applications with detailed organizational information. For example, a developer might use the Apollo API to retrieve company details to enhance a CRM system, providing sales teams with up-to-date information on potential clients.

Setting Up Your Apollo API Test Account

Before you can start using the Apollo API to access company data, you'll need to set up a test account. This involves obtaining an API key, which will allow you to authenticate your requests and interact with Apollo's extensive database.

Creating an Apollo Account

If you don't already have an Apollo account, you can sign up for a free trial on the Apollo website. This will give you access to the platform's features and allow you to explore its capabilities.

  • Visit the Apollo website and click on the "Sign Up" button.
  • Fill in the required information, such as your name, email, and company details.
  • Follow the instructions to complete the registration process.

Generating an Apollo API Key

Once your account is set up, you'll need to generate an API key to authenticate your requests. Apollo uses API key-based authentication, which is straightforward and secure.

  • Log in to your Apollo account and navigate to the API settings section.
  • Click on "Generate API Key" to create a new key.
  • Copy the API key and store it securely, as you'll need it to authenticate your API requests.

Understanding Apollo API Rate Limits

When using the Apollo API, it's important to be aware of the rate limits to ensure smooth operation. Apollo enforces rate limits based on your current pricing plan.

  • Daily limit: 300 requests
  • Hourly limit: 100 requests
  • Minute limit: 50 requests

Monitor your usage through the response headers provided by the API to avoid exceeding these limits. For more details, refer to the Apollo API documentation.

Apollo authentication documentation page.
sbb-itb-96038d7

Making API Calls to Retrieve Company Data with Apollo in PHP

To interact with the Apollo API and retrieve company data, you'll need to use PHP to make HTTP requests. This section will guide you through the process of setting up your PHP environment and making API calls to access Apollo's rich company data.

Setting Up Your PHP Environment for Apollo API Integration

Before making API calls, ensure your PHP environment is properly configured. You'll need PHP version 7.4 or higher and the cURL extension enabled to handle HTTP requests.

  • Verify your PHP version by running php -v in your terminal.
  • Ensure the cURL extension is enabled by checking your php.ini file or running php -m to list installed modules.

Installing Required PHP Dependencies

To simplify HTTP requests, you can use the Guzzle HTTP client, a popular PHP library. Install it using Composer:

composer require guzzlehttp/guzzle

Example Code to Fetch Company Data from Apollo API

With your environment set up, you can now write PHP code to make a GET request to the Apollo API and retrieve company data. Replace Your_API_Key with your actual API key.


require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'https://api.apollo.io/v1/organizations/enrich', [
    'headers' => [
        'Content-Type' => 'application/json',
        'Cache-Control' => 'no-cache',
        'X-Api-Key' => 'Your_API_Key'
    ],
    'query' => [
        'domain' => 'example.com'
    ]
]);

$data = json_decode($response->getBody(), true);
print_r($data);

Understanding the API Response and Verifying Success

The API response will contain detailed information about the company associated with the provided domain. You can verify the success of your request by checking the response status code and the data returned:

  • A status code of 200 indicates a successful request.
  • Inspect the $data array to view the company details.

Handling Errors and Understanding Apollo API Error Codes

When making API calls, it's crucial to handle potential errors. The Apollo API may return various error codes, such as:

  • 400 Bad Request: The request was invalid or cannot be served.
  • 401 Unauthorized: Authentication failed. Check your API key.
  • 429 Too Many Requests: Rate limit exceeded. Refer to the rate limits section.

Implement error handling in your code to manage these scenarios gracefully.

Best Practices for Apollo API Integration in PHP

When integrating with the Apollo API, it's essential to follow best practices to ensure security, efficiency, and maintainability of your application. Here are some key recommendations:

  • Securely Store API Keys: Always store your API keys securely, using environment variables or a secure vault, to prevent unauthorized access.
  • Implement Rate Limiting: Respect Apollo's rate limits by implementing logic to handle API call throttling, ensuring you don't exceed the allowed requests per minute, hour, or day.
  • Handle Data Consistently: Standardize and transform data fields as needed to ensure consistency across your application and integrations.

Enhance Integration Efficiency with Endgrate

Building and maintaining multiple integrations can be time-consuming and resource-intensive. Endgrate offers a streamlined solution by providing a unified API endpoint that connects to various platforms, including Apollo. This allows you to:

  • Save time and resources by outsourcing integration tasks and focusing on your core product development.
  • Build once for each use case, reducing the need for multiple integration efforts.
  • Provide an intuitive integration experience for your customers, enhancing user satisfaction.

Explore how Endgrate can simplify your integration processes by visiting Endgrate.

Read More

Ready to get started?

Book a demo now

Book Demo