Back

Magento 1 API Essential Guide

Aug 9, 20246 minute read

What type of API does Magento 1 provide?

Magento 1 supports the following types of APIs:

  1. SOAP API

    • Uses the SOAP protocol and WSDL for defining the API
    • Requires authentication using a username and API key
    • Provides functions like catalogProductInfo to retrieve product information
    • The SOAP endpoint URL is typically in the format: http://yourmagentohost/index.php/api/v2_soap?wsdl=1
  2. XML-RPC API

    • SOAP evolved as a successor to XML-RPC, implying Magento 1 likely supported XML-RPC as well, though it's not explicitly stated.
  3. REST API

    • While not mentioned specifically for Magento 1, REST APIs are discussed as an alternative to SOAP in later Magento versions.
    • REST was not the primary API type for Magento 1.

Magento 1 does not natively support GraphQL, which was introduced later for Magento 2.

Does the Magento 1 API have webhooks?

Based on the search results, it appears that the official Magento 1 API does not have built-in webhook capabilities. Here are the key points:

No Native Webhook Support

  1. Magento 1.x does not have native webhook functionality out of the box.

  2. The official API endpoints do not support webhooks directly.

Alternative Approaches

While webhooks are not natively supported, there are some alternative approaches that developers have suggested:

  1. Using Magento events: You can take advantage of Magento's observable events to trigger actions when certain events occur. Some relevant events mentioned include:

    • sales_order_place_after
    • checkout_onepage_controller_success_action
    • customer_register_success
  2. Implementing a queue system: To avoid slowing down the execution of the site, it's recommended to implement a queue system that can be processed via a cron job.

  3. Third-party extensions: While not specifically mentioned in the search results, there may be third-party extensions available that add webhook functionality to Magento 1.

Considerations

  1. Performance impact: Directly using Magento events for webhooks can slow down the execution by waiting for the call to complete.

  2. Custom implementation: You may need to create custom observers to detect the events you're interested in.

  3. Queue implementation: For high-traffic websites, implementing a queue system is recommended for better performance.

It's worth noting that while these search results primarily discuss Magento 1, some of the information may also apply to Magento 2. However, the specific implementation details may differ between versions.

Rate Limits and other limitations

Here are the key points about API Rate Limits for the Magento 1 API:

Default Rate Limits

  • By default, Magento 1 does not have built-in API rate limiting.

  • However, rate limiting can be implemented using third-party solutions or server configurations.

Configurable Rate Limiting

  • Rate limiting can be configured using Nginx or other web servers. For example:

    • Limit API requests to 1 per 10 seconds:

      set $magestack_api_limit one_per_ten_seconds;
      
    • Conditionally limit by user agent:

      if ($http_user_agent ~* "YandexBot") {
        set $magestack_api_limit one_per_ten_seconds;
      }
      
    • Conditionally limit by IP address:

      if ($remote_addr ~* "192\.168\.1\.1") {
        set $magestack_api_limit one_per_ten_seconds;
      }
      

Rate Limit Options

Some common rate limit options that can be configured:

  • 1 request per second
  • 12 requests per minute (1 per 5 seconds)
  • 6 requests per minute (1 per 10 seconds)
  • 2 requests per minute (1 per 30 seconds)
  • 1 request per minute (1 per 60 seconds)

Best Practices

  • Implement rate limiting to prevent API abuse and excessive resource consumption.

  • Configure different limits for authenticated users vs guest access.

  • Use Redis or a similar caching system to track request counts.

  • Return appropriate HTTP status codes (e.g. 429 Too Many Requests) when limits are exceeded.

  • Allow configuring limits via admin panel or CLI commands for flexibility.

Key Considerations

  • Rate limits should be set based on your API's capacity and expected usage patterns.

  • More restrictive limits may be needed for unauthenticated requests.

  • Monitor API usage and adjust limits as needed to balance performance and availability.

While Magento 1 does not have built-in rate limiting, implementing custom limits is recommended to protect the API from abuse and ensure stable performance. The exact limits will depend on your specific use case and infrastructure.

Latest API Version

Based on the search results, here are the key points regarding the most recent version of the Magento 1 API:

  1. The last major version of Magento 1 was Magento CE 1.9.x, released in 2014-2015 [1].

  2. Magento 1 reached end-of-life on June 30, 2020 [3].

  3. Despite reaching end-of-life, over 27,000 websites still use Magento 1 as of 2023 [3].

  4. The Magento 1.9 REST API does not have readily available official developer documentation [4].

  5. Magento 2 has replaced Magento 1 as the current supported version, with Magento 2.4.6 being the latest release as of March 14, 2023 [3].

Key points to consider:

  • Magento 1.9.x was the final major version of Magento 1 before it reached end-of-life.
  • Official support and documentation for Magento 1, including its API, is no longer maintained.
  • It's strongly recommended to migrate from Magento 1 to Magento 2 for security, performance, and feature updates.

Best practices:

  • If still using Magento 1, consider migrating to Magento 2 as soon as possible for continued support and security updates.
  • For those who must continue using Magento 1, look into third-party support options like Nexcess Safe Harbor [3].
  • When developing new integrations or features, focus on Magento 2 rather than the outdated Magento 1 platform.

In summary, while Magento 1.9.x was the most recent version of the Magento 1 API, it is no longer officially supported or updated. The focus has shifted entirely to Magento 2, with the latest version being 2.4.6 as of March 2023.

How to get a Magento 1 developer account and API Keys?

To get a developer account for Magento 1 to create an API integration, you need to follow these steps:

Register as a Developer

  1. Go to the Magento admin panel of your Magento 1 installation.
  2. Navigate to System > Web Services > REST - OAuth Consumers.
  3. Click on "Add New Consumer" to create a new API consumer/integration.

Configure the API Consumer

  1. Fill out the required information for the new consumer, including:
    • Name
    • Key
    • Secret
    • Callback URL (if applicable)
  2. Set the appropriate permissions for the API consumer based on what data and actions you want to allow.

Obtain API Credentials

  1. After saving the new consumer, you'll receive the following credentials:
    • Consumer Key
    • Consumer Secret
    • Access Token
    • Access Token Secret
  2. Save these credentials securely, as you'll need them to authenticate API requests.

What can you do with the Magento 1 API?

Here are the key data models you can interact with using the Magento 1 API, along with what is possible for each:

Products

  • Retrieve product information (name, SKU, price, etc.)
  • Create new products
  • Update existing product details
  • Delete products
  • Manage product categories
  • Manage product images
  • Associate products with websites

Customers

  • Retrieve customer information
  • Create new customer accounts
  • Update existing customer details
  • Delete customer accounts
  • Manage customer addresses

Orders

  • Retrieve order information
  • Create new orders
  • Update order status
  • Manage order items
  • Manage order addresses
  • Add order comments

Inventory

  • Retrieve stock levels
  • Update product stock quantities
  • Manage backorders and stock status

Categories

  • Retrieve category information
  • Create new categories
  • Update existing categories
  • Delete categories
  • Manage category hierarchy

Shopping Carts

  • Create and manage shopping carts
  • Add/remove items from carts
  • Apply coupons/discounts to carts
  • Convert carts to orders

Invoices

  • Create invoices for orders
  • Retrieve invoice information
  • Cancel invoices

Shipments

  • Create shipments for orders
  • Retrieve shipment information
  • Add tracking numbers

Attributes

  • Retrieve product attribute information
  • Create new product attributes
  • Update existing attributes

Websites/Stores

  • Retrieve website and store information
  • Associate products with websites

Summary

The Magento 1 API provides comprehensive access to core ecommerce data models, allowing you to manage products, customers, orders, inventory and more. It enables both reading and writing of data across most key areas of the system.