<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrii Chykharivskyi on Medium]]></title>
        <description><![CDATA[Stories by Andrii Chykharivskyi on Medium]]></description>
        <link>https://medium.com/@a.chykharivskyi?source=rss-1d2922814517------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*e487L0MMFXMUXu44GZBuPA.jpeg</url>
            <title>Stories by Andrii Chykharivskyi on Medium</title>
            <link>https://medium.com/@a.chykharivskyi?source=rss-1d2922814517------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:09:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.chykharivskyi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[API Integration Best Practices: The Complete Guide for Backend Developers]]></title>
            <link>https://medium.com/tenantcloud-engineering/api-integration-best-practices-the-complete-guide-for-backend-developers-0f5195c0316c?source=rss-1d2922814517------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f5195c0316c</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[api-development]]></category>
            <dc:creator><![CDATA[Andrii Chykharivskyi]]></dc:creator>
            <pubDate>Mon, 14 Jul 2025 08:51:10 GMT</pubDate>
            <atom:updated>2025-07-14T13:03:49.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUxvu0XgHSV8F5wXB_WaYA.png" /></figure><h3>Introduction</h3><p><strong>What is API integration?</strong> API integration represents the technical process which enables backend engineers to connect software systems that function independently. Backends use API integration to make unrelated systems communicate because most applications do not interact properly (spoiler: they don’t). The process of integration requires more work than engineers typically reveal. Learning <strong>how to use an API</strong> is essential for backend developers to establish connections between their systems and external services.</p><ul><li>Modern backend systems use third-party APIs extensively throughout their entire infrastructure.</li><li>The purpose of this guide is to assist engineers in building API integrations which provide security and maintenance capabilities.</li></ul><p>The API integration from a backend perspective represents the method to achieve service interoperability through code implementation.</p><h3>0. Requirements: Choosing the Right API or Partner</h3><p>Any integration project should begin by checking if the 3rd party API alongside its associated company fulfills your platform requirements. The complexity of integration management exceeds what APIs or vendors can provide regarding reliability and transparency and support capabilities. The core system of <a href="https://www.tenantcloud.com/">TenantCloud</a> functions through multiple external APIs. Our engineering teams use a set of requirements to verify that new integrations meet both technical standards and security requirements and operational standards while preventing partnership lock-ins with unreliable vendors. <strong>What to consider:</strong></p><ul><li>Technical maturity of the API and partner</li><li>Quality and completeness of documentation</li><li>The level of support and technical contact accessibility from the company</li><li>The API demonstrates stable operations through its versioning mechanisms and its transparent development plans</li><li>Your business requirements must be consistent with technical specifications.</li></ul><p>The evaluation of partners during initial stages prevents severe problems from developing in future operations.</p><h3>1. Understand the API You’re Integrating</h3><p>The first step in code creation should include thorough examination of the API which you plan to integrate.</p><p>The initial effort results in substantial advantages that appear later on. The initial time investment results in technical problem prevention while decreasing risks and preventing late-night maintenance of issues.</p><h4>Read the Docs — Fully 📚</h4><p>Most engineers skim documentation. Don’t be most engineers. Dig into:</p><ul><li>The <strong>API login process</strong> requires understanding OAuth flows together with token duration management and refresh strategies</li><li>The <strong>rate limits and quotas</strong> of the system extend beyond documented thresholds</li><li>The <strong>versioning approach</strong> of this system defines its methods for handling breaking changes through headers and URL paths as well as “surprise” updates</li><li><strong>Idempotency guarantees </strong>— Critical for implementing retry logic correctly</li></ul><p>The experienced engineers recognize how “it works” differs from “it works reliably in production.” The deeper knowledge of API behavior emerges when it faces stress conditions and maintenance windows as well as edge cases.</p><h4>Clarify the Use Case 🎯</h4><p>Challenge your product team with specific questions:</p><ul><li>“What exactly are we trying to accomplish with this integration?”</li><li>“What’s our fallback if this API is unavailable for 30 minutes?”</li><li>“The application requires data in real-time or does it function adequately with aggressive data caching?”</li></ul><p>This helps you:</p><ul><li>Avoid overengineering</li><li>Focus on what matters</li><li>Build a clean, testable abstraction</li></ul><h4>Use a Sandbox or Staging Environment 🧪</h4><p>If the API provides a <strong>test mode</strong> or <strong>sandbox</strong> feature use it:</p><ul><li>Test operations can be performed while protecting against damage to actual data</li><li>Explore edge cases</li><li>Simulate destructive actions (e.g., deletions)</li></ul><p>🚫 <strong>No sandbox available? </strong>The absence of a sandbox environment might require engineers to build mock servers which can replace API responses in development stages.</p><h4>Real-World Example: Rate Limit Blind Spot 🛠️</h4><p>A CRM integration development team built an external API connection to sync contact updates. The system operated without issues during staging tests until it began handling production traffic. The API rejected all incoming requests by returning 429 Too Many Requests errors within a short period.</p><p>Team members failed to discover both the rate limit documentation section and the need to process Retry-After headers.</p><p>The outcome consisted of failed updates and dissatisfied customers alongside emergency efforts to implement backoff functionality.</p><p>The understanding of API constraints during initial development would have prevented the deployment problems.</p><blockquote>Understanding the API’s constraints early would’ve saved the rollout.</blockquote><h3>2. Authentication &amp; Authorization Challenges</h3><p>API integration starts with authentication as its essential and primary requirement. Different authentication methods such as OAuth 2.0 API keys HMAC and JWT require unique implementation techniques and security risks.</p><p>Official documentation along with high-quality tutorials provide detailed information about authentication types but we will skip discussing their advantages and disadvantages. The most important aspect in practical applications is:</p><ul><li>Review documentation thoroughly to understand authentication sequences before initiating development work.</li><li>Proper implementation of token expiration and refresh logic should be performed. You should never rely on permanent token validity.</li><li>Secure credentials require storage outside the codebase since they should never be included in it. Secret managers, or vaults should be used to store credentials.If the API supports it, use IP whitelisting and scopes to minimize risk if a token is ever leaked.</li><li>You can implement IP whitelisting and scopes when the API supports them to reduce potential risks from token leaks.</li></ul><p>The use of non-expiring tokens creates a security vulnerability because attackers can keep using stolen or leaked tokens to access your API or third-party service without any time limit. Security standards and privacy laws including GDPR and SOC2 demand periodic credential rotation and expiration to minimize security risks.</p><p>A reliable integration begins with proper authentication management. Take time to read documentation or seek guidance from a trusted source whenever you encounter an unfamiliar authentication system.</p><h4>Token Expiration &amp; Refresh Strategies ⏳</h4><p>Tokens expire — that’s by design. Handle it with:</p><ul><li>Automatic <strong>refresh token flow</strong> if supported (OAuth 2.0)</li><li><strong>Graceful fallback</strong>: do not retry a request when if token expired as it’s unlikely that it will magically start working again</li><li>The correct method to store tokens requires careful planning while <strong>verifying tokens</strong> during failures</li></ul><p>Never hard-code tokens. Permanent tokens should not be used since all of them will eventually get revoked.</p><blockquote><strong>Real-world example:</strong>A proper implementation of OAuth 2.0 requires developers to understand how refresh tokens operate during their work with APIs. During my work experience I encountered situations which made my current refresh token invalid after logging in to the Test GraphQL tool in a service’s Developer Center. The backend integration started to fail in production with unexpected authentication errors until I discovered the issue. My account’s developer tools use caused a disruption to my existing integration without warning. This situation occurred because the platform performed silent refresh token rotations which limited the validity to one token at any time regardless of its origin. Services which perform refresh token rotation based on one active token at a time may invalidate your production credentials when their tools fail to separate developer sessions from live integrations.</blockquote><p>You might inadvertently disable your production account credentials when tools do not maintain separate developer sessions from active integration workflows.</p><p><strong>Takeaway:</strong> Always review token management details in the docs. The combination of developer tools with production accounts needs special attention according to the documentation because small errors will cause silent integration failures.</p><h4>Secure Storage of Credentials 🔐</h4><p>Hardcoding secrets in code or config files or environment variables? Don’t.</p><p>Instead:</p><ul><li>Secrets should be stored in <strong>vaults</strong> including HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, etc.</li><li>The use of <strong>CI/CD secrets management</strong> enables the injection of keys into builds during the process.</li></ul><p><strong>Remember</strong>: rotate credentials regularly and set up alerts for secret exposure.</p><h4>IP Whitelisting &amp; Scopes 🛡️</h4><p>Some APIs offer additional controls:</p><ul><li><strong>IP whitelisting</strong> to limit access from specific networks</li><li><strong>Scopes</strong> to limit what actions a token can perform</li></ul><p>If supported, use them. These measures minimize the attack area when tokens become compromised.</p><h4>Secure Your Webhook Endpoints 🔒</h4><ul><li>Webhook requests need verification to ensure they are genuine. Your application needs <strong>signature verification</strong> and secret token checks and IP allowlists to defend against spoofed or malicious calls.</li></ul><h3>3. Work With the Integration Partner Effectively</h3><h4>Build Human Relationships 🤝</h4><p>If the API provider offers a partnership program or technical support, <strong>use it</strong>. A real contact who can be a support engineer, solutions architect or account manager proves essential in many situations:</p><ul><li>Something breaks in production</li><li>You need clarification not found in the docs</li><li>You want early notice on upcoming changes</li></ul><p>APIs experience regular changes so having someone inside the system provides essential advantages for staying ahead of these updates.</p><blockquote>🔐 Tip: Use <a href="https://slack.com/connect">Slack Connect</a> for communication</blockquote><h4>Track Change Logs and Deprecation Notices 📓</h4><p>The active maintenance and <strong>versioning system</strong> of many APIs leads to periodic changes in their functionality.</p><p>Subscribe to:</p><ul><li><strong>Change logs</strong> or API release notes</li><li><strong>Email updates</strong> or product newsletters</li><li><strong>Status pages</strong> for outages or incident history</li></ul><p>Your team requires an internal system using Slack channel JIRA task or recurring review for updates.</p><h4>Ask Questions Early ❓</h4><p>Don’t make assumptions — <strong>ask questions</strong>.</p><p>Unclear specifications about rate limits and concurrency and retry strategies and usage quotas typically result in production problems. Early communication ensures you will not need to guess which leads to bugs.</p><h4>Report Bugs (and Provide Good Repro Steps) 🛠️</h4><ul><li>If you find a bug — <strong>create a bug report</strong> which should include steps to reproduce the issue together with logs and sample requests and responses. Your problem resolution process will become faster while the API team develops trust in you through this method.</li></ul><h4>Contribute to the Community 🏷️</h4><p>When you discover a workaround or solution for the problem share it through the forum or repository or Slack channel related to your community. Your investment of social capital today will benefit you when you need assistance in the future.</p><blockquote><strong>Real-world example:</strong> Our payment gateway integration faced problems because of the inconsistent responses that occurred between the sandbox and production environments. Webhook events performed without errors during testing but became non-responsive after deploying our application to production. The developer forums revealed that engineers experienced identical problems to us. The solution they provided was not found in official documentation. Joining the provider’s community Slack allowed us to discuss the solution with their support team for production confirmation.</blockquote><p>Your deep understanding of the API before integration will reduce numerous typical API integration errors that cause difficulties in future development.</p><h3>4. Design Your Integration Layer</h3><h4>Use an Abstraction Layer or API Client Wrapper 🧱</h4><p>The codebase should never contain separate HTTP calls in different locations.</p><p>Create a <strong>specific service class</strong> or <strong>client module</strong> to envelop the API operations.</p><ul><li>Centralize authentication, headers, and error handling — it will make mocking and testing dramatically easier</li><li>Reduce boilerplate across your application</li></ul><p>The defined contract between your system and external services functions as an interface which prevents unexpected occurrences.</p><h4>Normalize External Data to Your Domain 🔁</h4><p>The implementation of third party data structures must stay separate from your business logic.</p><p>Transform responses into your own <strong>internal models</strong>, even if they look nearly identical.</p><p>Why?</p><ul><li>The ability to define field names and types and structure remains within your control.</li><li>Your system will remain independent from changes made to upstream components.</li><li>You can merge data from multiple APIs into one unified shape.</li></ul><h4>Avoid Tight Coupling to External APIs 🧩</h4><p>Your business logic must function based on <strong>domain</strong> <strong>principles</strong> instead of depending on ExternalUserDTO or WebhookPayloadV2 .</p><p>The tight integration between the API and your system prevents smooth changes to the API structure.</p><p>Instead:</p><ul><li>Keep logic pure and use adapters at the boundaries</li><li>Abstract API quirks behind stable interfaces</li></ul><h4>Think Ahead: Service Boundaries 🔄</h4><p>The current API which you love will eventually require updates.</p><ul><li>Vendors shut down</li><li>Pricing models shift</li><li>Better tools emerge</li></ul><p>A well-defined <strong>service boundary</strong> enables smooth transitions to different APIs while minimizing system disruptions. Your internal logic should function independently from the integration provider because all it needs to know is that the integration functions correctly.</p><h4>Use Feature Flags for Integration Control 🔀</h4><p>All abstractions require operational flexibility at some point. You can manage API integration status through <strong>feature flags</strong> which allow global or user-specific or environment-based control without requiring redeployment. The <strong>feature flag</strong> system provides organizations with essential control features. The ability to stage product deployments and perform emergency shutdowns during outages as well as execute provider transitions through gradual processes exists within this system.</p><h3>5. Handle and Classify Errors Gracefully</h3><p>Any API which claims to be reliable will experience errors. The integration system must demonstrate resilience and predictability while implementing intelligent failure response mechanisms.</p><h4>Classify Errors Intelligently 🚦</h4><p><strong>🔸 4xx — Client Errors</strong></p><ul><li>Your system should check for three main categories of errors which stem from client-side issues such as requests that fail to meet standards and authentication errors and missing necessary parameters.</li><li>Common examples: 401 Unauthorized, 403 Forbidden, 422 Unprocessable Entity.</li><li>Log every failed request and send alerts only if necessary before resolving the request.</li></ul><p><strong>🔸 5xx — Server Errors</strong></p><ul><li>These mean the external service is having issues.</li><li>You should escalate the request or alert someone after continuous request failures instead of continuing to retry indefinitely.</li></ul><p><strong>🔸 Network Issues / Timeouts</strong></p><ul><li>These are transient and often recoverable.</li><li>Use <strong>retry logic</strong> with backoff.</li><li>Add <strong>circuit breakers</strong> to prevent cascading failures.</li></ul><h4>Graceful Degradation &amp; User Feedback 👤</h4><p>API errors need not destroy the user experience. Your application should include <strong>graceful degradations</strong> through error messages which provide actionable information and alternative content instead of complete system breakdowns. Display cached content to users when real-time data fails to load or let them know when to retry. Users can continue essential operations while maintaining trust through transparent feedback when systems encounter outages or third-party platform disruptions.</p><p><strong>Why:</strong> This method reduces user discontent while providing functional capabilities during demanding situations to create enduring trust in your platform.</p><h4>Respect Rate Limits 🕰️</h4><p>Rate limits exist in most APIs through either IP addresses or tokens or specific endpoint restrictions.</p><ul><li>Read 429 Too Many Requests responses carefully.</li><li>Look for Retry-After headers or custom limit headers (e.g., X-RateLimit-Remaining).</li><li>Implement <strong>backoff strategies</strong> when you’re getting close.</li></ul><p>The use of rate limits for abuse purposes will result in either throttling or permanent banning.</p><h4>Make POSTs Idempotent When Needed ♻️</h4><p>Many APIs provide <strong>idempotency keys</strong> which operate particularly well for payment transactions as well as resource creation tasks.</p><ul><li>A request can safely undergo retries because it maintains its idempotent property.</li><li>The operation should always use this feature when it produces effects that modify external systems such as when charging a customer or sending messages.</li></ul><p>If the API system lacks support for idempotency keys implement your own deduplication system to prevent duplicate requests.</p><h3>6. Logging &amp; Monitoring</h3><p>The first and most reliable protection against integration failure occurs through log data. Appropriate logging of external API interactions determines whether a problem solution requires five minutes or five hours.</p><h4>Log Every External Call 🧾</h4><p>The <strong>logging system</strong> should record all API requests by including:</p><ul><li><strong>Endpoint</strong> and <strong>HTTP method</strong></li><li><strong>Status code</strong> (success or failure)</li><li><strong>Response time</strong> (in ms)</li><li><strong>Request ID</strong>, if provided</li></ul><p>The system enables future identification of slow calls and failing endpoints and systemic problems across different time periods.</p><h4>Redact Sensitive Data 🕵️</h4><p>Do <strong>not</strong> <strong>log</strong>:</p><ul><li>API keys or secrets</li><li>Access tokens or JWTs</li><li>Personally Identifiable Information (PII)</li></ul><p>Log data must be masked or redacted prior to transmission especially when the logs are sent to external platforms.</p><blockquote>🔐 Tip: Enable structured logging (e.g., JSON format) for easier parsing and alerting.</blockquote><h4>Use Centralized Logging &amp; Dashboards 📡</h4><p>Scattered logs are useless. Send external API requests to a <strong>unified observability system</strong> which includes <a href="https://www.elastic.co/">ELK</a> (Elasticsearch, Logstash, Kibana) or use Datadog or Grafana with Loki or deploy cloud-native tools such as AWS CloudWatch or Azure Monitor.</p><p>This allows you to:</p><ul><li>Search across services</li><li>Visualize API latency trends</li><li>Correlate logs with infrastructure metrics</li></ul><h4>Set Up Alerts Early 🚨</h4><p>Don’t wait for customers to report issues.</p><ul><li>Establish <strong>alert systems</strong> to detect repeated failures and increasing numbers of 4xx/5xx errors and prolonged response times.</li><li>Send alerts to the <strong>appropriate team members</strong> instead of broadcasting through an ignored generic communication channel.</li><li>Use <strong>severity levels</strong> — not every 4xx is worth waking up for.</li></ul><h3>7. Resilient Integration Design: Testing and Operational Fault Tolerance</h3><p>APIs experience occasional outages that should not cause your backend system to fail. Your system should become more resilient when integrating by planning for worst-case scenarios which enable it to function properly even during system failures.</p><h4>Use Retries (But Do It Smart) 🔁</h4><p>Not all errors are final. Many are transient: timeouts, 500s, or connection resets.</p><ul><li>Retry <strong>only on safe-to-repeat failures</strong> (e.g., 5xx, timeouts).</li><li>Use <strong>exponential backoff</strong> (e.g., wait 1s, then 3s, then 6s…) to avoid overwhelming the API.</li><li>Your system should have a defined number of <strong>retry attempts</strong> to stop infinite attempts</li></ul><p>Try to avoid automatic retries for 4xx errors and authentication problems because they cannot resolve by themselves.</p><figure><img alt="Meme of Fry from Futurama squinting suspiciously with the caption: “Not sure if REST stands for relaxation” — a humorous take on REST APIs and their name." src="https://cdn-images-1.medium.com/max/300/0*4yZxNFZfvlqKdMq3.jpg" /><figcaption>Source: <a href="https://s7280.pcdn.co/wp-content/uploads/2019/07/API-Meme-300x225.jpg.optimal.jpg">PCDN</a></figcaption></figure><h4>Use Circuit Breakers ⛔</h4><p>API failures can cause your system to collapse completely. Circuit breakers protect your system from this occurrence.</p><ul><li>The system should activate an automatic shutdown mechanism after encountering multiple failed attempts.</li><li>Outgoing requests must be stopped during this period.</li><li>Check if the service has returned to operation after a specified cooldown period.</li></ul><p>Your backend will receive protection from this approach which enables your system to fail promptly instead of prolonging the failure process.</p><h4>Cache Non-Volatile Data 📦</h4><p>Each API response does not require immediate retrieval from the API server. Static or slow-changing data (e.g., currency codes, config values, feature flags) requires implementation of a caching solution.</p><ul><li>✅ Cache results in memory (e.g., in-process store)</li><li>✅ Use persistent cache (e.g., Redis, Memcached) when needed</li></ul><p>The best results will be achieved by implementing <strong>TTLs</strong> (time-to-live) and fallback strategies correctly. <strong>Automatic cache invalidation</strong> should be implemented to remove or update cached data when you know it has become outdated (for example, in response to a webhook or a specific event). Properly implemented caching systems decrease system loads and speed up response times.</p><h4>Queue External Calls When Needed 📬</h4><p>Your <strong>users should not experience delays</strong> when the API becomes unreliable or performs slowly.</p><ul><li>Push the task into a <strong>message queue</strong> (e.g., RabbitMQ, SQS, Kafka).</li><li>Process it asynchronously with a worker.</li><li>Your database should track the status or you should notify users about completion.</li></ul><p>Non-critical tasks such as email sending and analytics synchronization and downstream event triggering require this approach.</p><p>API integration with third-party services requires more than basic functionality because you must maintain its operational state. Testing provides assurance that your integration will function without errors when upstream changes occur.</p><h4>Mock External APIs in Unit Tests 🧪</h4><p>The execution of unit tests should be both rapid and self-contained. That means:</p><ul><li>Test doubles which include stubs or fakes should be used to mock external HTTP calls during your testing process.</li><li>Simulate both success and failure scenarios.</li><li>Check that your code properly manages all scenarios while focusing on successful outcomes only.</li></ul><blockquote>Bonus: By implementing proper mocking techniques you can test unusual situations which the real API does not make easily accessible.</blockquote><h4>Use Contract Tests for Critical Interactions 📄</h4><p>When your integration depends heavily on another service’s behavior through precise response fields and status codes you should implement <strong>contract testing</strong>.</p><ul><li>The verification process should ensure the requested and received data structures match the actual ones.</li><li>Tools like Pact or <a href="https://assertible.com/">Assertible</a> can help.</li><li>The risk of API evolution-induced breakage will be minimized through this approach.</li></ul><p>When you lack full-blown contract tools <strong>documentation and response shape validation</strong> will deliver significant benefits.</p><h4>Run End-to-End Tests Against Sandbox Environments 🌐</h4><p>End-to-End tests should run against sandbox environments to validate the system properly.</p><p>Even though mocks and contracts provide excellent results they do not represent actual systems in operation.</p><ul><li>Run your tests in the provider’s sandbox or staging environment to execute live E2E tests.</li><li>Validate authentication, permissions, and real-world request flows.</li><li>Schedule regular runs in CI to catch breaking changes early.</li></ul><blockquote>🔐 Tip: The testing environment should be separated from your primary test suite to prevent performance delays.</blockquote><h4>Test Failures On Purpose 💣</h4><p>API integration bugs primarily emerge during unsuccessful attempts rather than successful ones.</p><p>Create test simulations that include time-outs and retry attempts and rate limitations and incorrect response formats.</p><ul><li>What happens if the API is down?</li><li>What happens if a retry fails twice, then succeeds?</li></ul><p>Testing the system through its most <strong>challenging paths</strong> will result in better production resilience.</p><h3>8. Versioning and Change Management</h3><p>APIs undergo development which breaks your integration when you fail to adapt to their updates. Your system remains stable during service shifts through smart versioning and change management systems.</p><h4>Always Use Versioned Endpoints or Headers 🧩</h4><p>If the API offers versioning — <strong>use it</strong>.</p><ul><li>Prefer versioned <strong>URLs</strong> (e.g., /v1/users) or <strong>headers</strong> (X-API-Version: 2).</li><li>Pin your integration to a <strong>specific version</strong>, not just “latest”.</li></ul><p>Using versioned endpoints or headers creates a stable contract that shields your system from unplanned breaking changes</p><blockquote>🔐 Tip: If the provider does not provide versioning you should implement an internal abstraction to manage change exposure.</blockquote><h4>Watch for Deprecations and Upgrade Proactively 🛎️</h4><p>The sudden appearance of shutdown notifications one week before a major API change should not surprise you.</p><ul><li>Monitor <strong>changelogs</strong>, <strong>developer updates</strong>, and <strong>status pages</strong>.</li><li>Subscribe to newsletters or release feeds if available.</li><li>Set <strong>calendar reminders</strong> to review integration versions quarterly.</li></ul><p>Make sure your roadmap includes upgrade time especially when you are at version 1 and version 3 has already been released.</p><h4>Be Tolerant to Unknown Fields 🤖</h4><p>Good API clients are <strong>forward-compatible</strong>. That means:</p><ul><li>Do not crash when a response includes an unlisted or undocumented field.</li><li>Do not tightly couple deserialization to a fixed schema (especially with strict languages or validation libraries).</li><li>Ignore extra fields gracefully, but <strong>log them</strong> — they might signal upcoming changes.</li></ul><p>A single mindset approach will help you avoid numerous hidden API implementation errors that can occur during deployment.</p><h3>9. Documentation and Knowledge Sharing</h3><p>An integration fails to deliver its potential if its implementation knowledge resides only with one person. The most successful teams ensure that their integrations remain simple to understand and extend while also being easy to debug regardless of time passing. That starts with documentation.</p><h4>Document the Integration Flow 🧭</h4><p>Avoid simply sharing links to the vendor <strong>API documentation</strong> pages.</p><p>Instead, describe how <em>your</em> system interacts with it:</p><ul><li>What endpoints are used?</li><li>What triggers the calls?</li><li>Where are credentials stored?</li><li>How do retries and error handling work?</li></ul><blockquote>🔐 Tip: The actual integration logic should be documented in your internal wiki or repo README instead of just the API surface.</blockquote><h4>Onboarding Guides for New Developers 👋</h4><p>The following information should be documented by you for future reference as well as for your current teammates:</p><ul><li>Setup instructions (API keys, env vars, sandbox access)</li><li>Where to find logs or trace failures</li><li>Common pitfalls or gotchas</li><li>How to test or mock the integration</li></ul><blockquote>🔐 Tip: Document the setup process for the integration if the onboarding process takes more than one hour because this will allow future team members to complete it in less than ten minutes.</blockquote><h4>Share cURL Examples and Postman Collections 🔧</h4><p>For manual testing or debugging, include:</p><ul><li><strong>cURL snippets</strong> with typical requests</li><li><strong>Postman collections</strong> with pre-configured endpoints and environments</li></ul><p>This process benefits both engineers and QA staff and support personnel and integration partners by allowing them to conduct tests efficiently without starting from scratch</p><h4>Wrapping Up ✅</h4><p>Third-party API integrations need continuous maintenance because they change over time and sometimes fail and need new design approaches.</p><p>By applying these practices:</p><ul><li>You’ll catch problems earlier</li><li>You’ll onboard teammates faster</li><li>You’ll ship integrations that survive version bumps, outages, and scale</li></ul><p>Build with care. Expect instability. Plan for the long game.</p><h3>Conclusion</h3><ul><li>Third-party API integrations need both coding skills and strong process-based management to achieve success.</li><li>Prioritize maintainability, resilience, and observability.</li><li>Think of the API as a moving piece — not a static utility.</li></ul><p>A seasoned engineer once said: “The API integration that never breaks isn’t the one with the fewest lines of code — it’s the one designed with the humility to expect failure.” Your future self will thank you for the care you take today. Now go build something that lasts.</p><p>You have reached the end of this article and I appreciate your dedication to reading it through. Also, I would like to thank my friend Mykola for his help in editing the text.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f5195c0316c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tenantcloud-engineering/api-integration-best-practices-the-complete-guide-for-backend-developers-0f5195c0316c">API Integration Best Practices: The Complete Guide for Backend Developers</a> was originally published in <a href="https://medium.com/tenantcloud-engineering">tenantcloud-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create AWS Lambda Python function using Docker container?]]></title>
            <link>https://medium.com/tenantcloud-engineering/how-to-create-aws-lambda-python-function-based-on-docker-container-b388f989217d?source=rss-1d2922814517------2</link>
            <guid isPermaLink="false">https://medium.com/p/b388f989217d</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Andrii Chykharivskyi]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 14:54:19 GMT</pubDate>
            <atom:updated>2024-10-23T13:39:55.630Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Hi, I’m Andrii and I’m a software engineer at <a href="https://www.tenantcloud.com/">TenantCloud</a>. Recently, we have started to use AWS Lambda to solve many simple tasks: converting html to pdf, image resizer, pdf editor, pdf merger, etc. And Lambda does a great job.</p><p>Today we’ve created a real example of AWS Lambda Python function from scratch, based on container image. Our function will receive S3 PDF file path and return PDF file pages count. Also our function will be able to work with MinIO(Object Storage, a good variant for local environments).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocMPZ_Vf5vv2T03dJXH6fw.png" /><figcaption>Options to create your Lambda function</figcaption></figure><h3>Requirements</h3><ul><li><a href="https://docs.docker.com/get-started/">Docker</a></li><li><a href="https://git-scm.com/downloads">GIT</a></li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI</a></li><li><a href="https://signin.aws.amazon.com/signin">AWS Account</a></li></ul><h3>Application</h3><p>Create empty directory <strong><em>lambda-pdf-pages</em></strong><em>. </em>Inside our project create file <strong><em>requirements.txt</em></strong> (this file includes packages that should be installed for our function).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/545d2198f784782229d8b803ba6ef862/href">https://medium.com/media/545d2198f784782229d8b803ba6ef862/href</a></iframe><p><a href="https://pypi.org/project/PyPDF3/">PyPDF3</a> is a library built as a PDF toolkit. It is capable of extracting document information, merging documents, cropping pages, etc.</p><p>After that, create file <strong><em>app.py</em></strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cab6e5a246d91b0769255acdb6f04eab/href">https://medium.com/media/cab6e5a246d91b0769255acdb6f04eab/href</a></iframe><p>The function <strong><em>handler</em></strong> will be the initial point of our application. First argument is an event that contains passed information. The second argument is context, this object provides information about the function, execution environment, etc. As an argument we pass the name of the S3(or MinIO) bucket and path for our file. After that, we download the file and with the help of <strong><em>PyPDF3</em></strong> get the count of pages from the file. The container image must be able to run on a read-only file system. Your function code can access a writable <strong><em>/tmp</em></strong>.</p><blockquote><em>Remember: </em><strong>/tmp</strong><em>, not </em><strong>tmp</strong><em>. Naming </em><strong><em>tmp</em></strong><em> will work locally, but not at the AWS Lambda.</em></blockquote><p>Inside the project, create a folder <strong><em>src</em></strong>, and inside it a file <strong><em>s3_client.py</em></strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e0ae84aa0d7e7fbe798a36a6c623747/href">https://medium.com/media/2e0ae84aa0d7e7fbe798a36a6c623747/href</a></iframe><p>We do not need to install the boto3 package, because it’s already included. If we want to get files from <strong><em>S3,</em></strong> we don’t need to use custom environment variables for accessing <strong><em>S3</em></strong>. Use <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime">defined <strong>AWS Lambda</strong> environment</a> keys naming in <strong><em>.env</em></strong>. If we want use MinIO, we need pass environment variable <strong>AWS_S3_ENDPOINT_URL</strong>, disable verifying and set “signature_version” as s3v4.</p><blockquote>You don’t need to configure AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY for each AWS Lambda function, they will be obtained automatically from the function’s execution role.</blockquote><h3>Container Image</h3><p>Create file <strong><em>Dockerfile</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4c2b4d8639dc842aa7d3538aa0e9e18/href">https://medium.com/media/b4c2b4d8639dc842aa7d3538aa0e9e18/href</a></iframe><p>Create <strong><em>docker-compose.yml</em></strong> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee9afaba1d6f3739a3377a4b376279a5/href">https://medium.com/media/ee9afaba1d6f3739a3377a4b376279a5/href</a></iframe><p>Create and fill <strong><em>.env</em></strong> with values from your <strong>AWS </strong>account.</p><pre>AWS_ACCESS_KEY_ID=<br>AWS_SECRET_ACCESS_KEY=<br>AWS_DEFAULT_REGION=</pre><p>Now, we build container image and test our function locally. Our function will be available on port 3001.</p><p>Inside your project folder run next command:</p><pre>docker-compose up -d --build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVmo2VhbRauEH9MEEXFcsg.png" /><figcaption>Container</figcaption></figure><p>Upload PDF file to your AWS Bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHJl9vpfPalWEQOxcVR0IA.png" /><figcaption>Uploaded file</figcaption></figure><p>For testing run the following command:</p><pre>curl -XPOST &quot;<a href="http://localhost:3001/2015-03-31/functions/function/invocations">http://localhost:3001/2015-03-31/functions/function/invocations</a>&quot; -d &#39;{&quot;s3_bucket_name&quot;: &quot;YOUR_BUCKET_NAME&quot;, &quot;file_path&quot;: &quot;YOUR_FILE_PATH&quot;}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CazdRDbu3qTU5gEDdJaI8w.png" /><figcaption>Execution result</figcaption></figure><h3>AWS ECR image uploading</h3><p>After installing <strong>AWS CLI </strong>don`t forget to configure <strong>AWS CLI</strong> options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O8a01_xIBUm6Hkvu3uyTnA.png" /><figcaption>aws configure</figcaption></figure><p>Login into <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html#cli-authenticate-registry">AWS ECR</a></p><pre>aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com</pre><blockquote>123456789012 is your <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html">AWS Account ID</a></blockquote><p>Create repository inside <strong>AWS Elastic Container Registry</strong>.</p><pre>aws ecr create-repository --repository-name pdf-pages --image-scanning-configuration scanOnPush=true --image-tag-mutability MUTABLE</pre><p>Tag your container image</p><pre>docker tag  lambda-pdf-pages_pdf-pages:latest 123456789012.dkr.ecr.us-east-1.amazonaws.com/pdf-pages:latest</pre><p>Push image to <strong>AWS ECR</strong></p><pre>docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/pdf-pages:latest</pre><p>After successful execution of the command above, we can go to the page <strong>AWS ECR </strong>and see the repository with our image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xnVjY-BmX9Y1Zq4CvujTQ.png" /><figcaption>Repository with our image</figcaption></figure><h3>Function creating</h3><p>First of all, we need to create <strong>AWS IAM</strong> role that will be attached to our future function as <strong>Execution Role.</strong></p><pre>aws iam create-role --role-name lambda-pdf-pages \<br>  --assume-role-policy-document &#39;{&quot;Version&quot;:&quot;2012-10-17&quot;,&quot;Statement&quot;:[{<br>  &quot;Sid&quot;: &quot;&quot;,&quot;Effect&quot;:&quot;Allow&quot;,&quot;Principal&quot;:{&quot;Service&quot;:&quot;lambda.amazonaws.com&quot;},&quot;Action&quot;:&quot;sts:AssumeRole&quot;}]}&#39; \<br>  --output text \<br>  --query &#39;Role.Arn&#39;<br><br>aws iam put-role-policy --role-name lambda-pdf-pages \<br>  --policy-name &quot;lambda-pdf-pages-policy&quot; \<br>  --policy-document &#39;{&quot;Version&quot;:&quot;2012-10-17&quot;,<br>      &quot;Statement&quot;:[{ &quot;Effect&quot;:&quot;Allow&quot;,&quot;Action&quot;:[&quot;s3:*&quot;],&quot;Resource&quot;:&quot;arn:aws:s3:::*&quot;}]}&#39;</pre><figure><img alt="sdff" src="https://cdn-images-1.medium.com/max/1024/1*1FIUb90FHGSbvkOYaJGang.png" /><figcaption>AWS IAM role after execution of the command above</figcaption></figure><pre>aws lambda create-function --function-name pdf-pages \<br>  --role &quot;arn:aws:iam::123456789012:role/lambda-pdf-pages&quot; \<br>  --description &quot;Study function example&quot; \<br>  --package-type Image  \<br>  --code ImageUri=123456789012.dkr.ecr.us-east-1.amazonaws.com/pdf-pages:latest</pre><p>Now, we can go to the AWS Lambda page and go to our function view page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZDEleEgWZr9RjtMqKE8pg.png" /></figure><p>The last stage is testing our function. Previously, we tested the execution result locally, now we will do it on the AWS site. Go to the test tab, create a test event specifying the bucket and the path to the file.</p><p>Green color indicates that everything was successful. Our function is ready to go. Hooray!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*isBHXza6a6EOd43p-UbbSQ.png" /></figure><h3>Conclusion</h3><p>Why did we choose AWS Lambda over other serverless solutions? The service has excellent and easy integration with other AWS services, includes free executions, supports most languages. It`s very useful for tasks like file editing, file converting, etc. This serverless solution allows us not to keep tools like Ghostscript, Libreoffice, Wkhtmltopdf in the main project.</p><p>You should also use AWS Lambda function versioning, aliases and of course set up CI/CD to easily update your function. We will talk about this soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b388f989217d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tenantcloud-engineering/how-to-create-aws-lambda-python-function-based-on-docker-container-b388f989217d">How to create AWS Lambda Python function using Docker container?</a> was originally published in <a href="https://medium.com/tenantcloud-engineering">tenantcloud-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>