Endpoints
The Partner Services API is structured to support various environments to facilitate development, testing, and production workflows. This section provides an overview of the different environments and best practices for working with the API in each stage of your integration process.
Environments
Development Environment
URL:
https://dev-api.partner-services.comPurpose: This environment is used for initial development and testing of API integrations. It allows developers to experiment and validate their integration logic without affecting any real data.
Best Practices:
Use mock data to test API endpoints.
Implement comprehensive error handling and logging to capture issues early.
Regularly update to the latest API version to stay aligned with new features and fixes.
Test Environment
URL:
https://test-api.partner-services.comPurpose: The test environment is a staging area that closely mirrors the production environment. It is used for more rigorous testing, including functional, integration, and performance testing.
Best Practices:
Conduct end-to-end testing with realistic data to ensure the integration works as expected.
Perform load testing to understand the performance characteristics of your integration.
Validate that all edge cases and error conditions are handled properly.
Acceptance Environment
URL:
https://acceptance-api.partner-services.comPurpose: This environment is used for final user acceptance testing (UAT). It provides a controlled setting where stakeholders can verify the integration against predefined acceptance criteria.
Best Practices:
Ensure all features meet the acceptance criteria before moving to production.
Collaborate with stakeholders to gather feedback and make necessary adjustments.
Validate that security and compliance requirements are met.
Production Environment
URL:
https://api.partner-services.comPurpose: The production environment is the live environment where the API handles real user data and transactions. This environment is optimized for performance, reliability, and security.
Best Practices:
Monitor API usage and performance using analytics and logging tools.
Implement rate limiting and throttling to manage API traffic and ensure service availability.
Keep API keys and sensitive information secure and rotate them regularly.
Example Configuration for .NET
Here’s an example of how you might configure your .NET application to switch between different environments based on the build configuration:
AppSettings.json:
{ "Environment": "Development", "ApiUrls": { "Development": "https://dev-api.partner-services.com", "Test": "https://test-api.partner-services.com", "Acceptance": "https://acceptance-api.partner-services.com", "Production": "https://api.partner-services.com" } }Program.cs:
using System; using System.Net.Http; using System.Net.Http.Headers; using Microsoft.Extensions.Configuration; namespace PartnerServicesApiExample { class Program { private static readonly HttpClient client = new HttpClient(); private static IConfiguration Configuration; static void Main(string[] args) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); Configuration = builder.Build(); var environment = Configuration["Environment"]; var apiUrl = Configuration[$"ApiUrls:{environment}"]; var apiKey = Environment.GetEnvironmentVariable("PARTNER_SERVICES_API_KEY"); client.BaseAddress = new Uri(apiUrl); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); // Example API call var applicationId = 123; var response = client.GetAsync($"application/{applicationId}").Result; if (response.IsSuccessStatusCode) { var responseData = response.Content.ReadAsStringAsync().Result; Console.WriteLine(responseData); } else { Console.WriteLine($"Error: {response.StatusCode}"); var errorData = response.Content.ReadAsStringAsync().Result; Console.WriteLine(errorData); } } } }
Switching Environments
To switch environments, simply update the Environment value in appsettings.json or use environment-specific configuration files (e.g., appsettings.Development.json, appsettings.Production.json). This approach ensures your application is flexible and can easily switch between environments as needed.
By structuring your integration to support multiple environments, you can ensure robust development, thorough testing, and reliable production deployments, making the most of the Partner Services API.
Last updated