{"id":3222,"date":"2026-01-13T16:06:34","date_gmt":"2026-01-13T08:06:34","guid":{"rendered":"https:\/\/teen.aiproinstitute.com\/?p=3222"},"modified":"2026-01-13T16:17:50","modified_gmt":"2026-01-13T08:17:50","slug":"api-integration-guide","status":"publish","type":"post","link":"https:\/\/teen.aiproinstitute.com\/zh\/api-integration-guide\/","title":{"rendered":"API Integration Guide"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"3222\" class=\"elementor elementor-3222\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ef1dc6f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ef1dc6f\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-fbff897\" data-id=\"fbff897\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-27d1294 elementor-widget elementor-widget-html\" data-id=\"27d1294\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>API Integration Guide - AiPro Institute<\/title>\n    <style>\n        * {\n            margin: 0;\n            padding: 0;\n            box-sizing: border-box;\n        }\n        \n        body {\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n            background: #ffffff;\n            color: #2c3e50;\n            line-height: 1.6;\n            padding: 20px;\n        }\n        \n        .container {\n            max-width: 1200px;\n            margin: 0 auto;\n            background: white;\n            padding: 40px;\n            border-radius: 12px;\n        }\n        \n        .header {\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            color: white;\n            padding: 40px;\n            border-radius: 12px;\n            margin-bottom: 40px;\n            text-align: center;\n        }\n        \n        .header h1 {\n            font-size: 3em;\n            margin-bottom: 10px;\n            color: white;\n        }\n        \n        .header .subtitle {\n            font-size: 1.3em;\n            opacity: 0.95;\n            color: white;\n        }\n        \n        .branding {\n            text-align: center;\n            margin-bottom: 30px;\n            font-size: 1.8em;\n            font-weight: bold;\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            -webkit-background-clip: text;\n            -webkit-text-fill-color: transparent;\n            background-clip: text;\n        }\n        \n        .member-badge {\n            display: inline-block;\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            color: white;\n            padding: 8px 20px;\n            border-radius: 25px;\n            font-size: 0.9em;\n            font-weight: 600;\n            margin-bottom: 20px;\n        }\n        \n        .section {\n            margin-bottom: 50px;\n        }\n        \n        .section-title {\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            color: white;\n            padding: 20px 30px;\n            border-radius: 10px;\n            font-size: 2em;\n            margin-bottom: 25px;\n            font-weight: 700;\n        }\n        \n        .subsection {\n            margin-bottom: 30px;\n            padding: 25px;\n            background: #f8f9fa;\n            border-radius: 10px;\n            border-left: 5px solid #7B3FF2;\n        }\n        \n        .subsection h3 {\n            color: #7B3FF2;\n            font-size: 1.6em;\n            margin-bottom: 15px;\n            font-weight: 600;\n        }\n        \n        .info-box {\n            background: linear-gradient(135deg, rgba(123, 63, 242, 0.08) 0%, rgba(0, 168, 232, 0.08) 100%);\n            border-left: 4px solid #7B3FF2;\n            padding: 20px;\n            margin: 20px 0;\n            border-radius: 8px;\n        }\n        \n        .info-box strong {\n            color: #7B3FF2;\n            display: block;\n            margin-bottom: 10px;\n            font-size: 1.1em;\n        }\n        \n        .code-block {\n            background: #1e1e1e;\n            color: #d4d4d4;\n            padding: 20px;\n            border-radius: 8px;\n            overflow-x: auto;\n            margin: 15px 0;\n            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;\n            font-size: 0.95em;\n            line-height: 1.5;\n            border: 2px solid #7B3FF2;\n        }\n        \n        .code-block .comment { color: #6A9955; }\n        .code-block .keyword { color: #569CD6; }\n        .code-block .string { color: #CE9178; }\n        .code-block .function { color: #DCDCAA; }\n        .code-block .number { color: #B5CEA8; }\n        \n        .two-column {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 20px;\n            margin: 20px 0;\n        }\n        \n        .comparison-table {\n            width: 100%;\n            border-collapse: collapse;\n            margin: 20px 0;\n            background: white;\n            box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n            border-radius: 8px;\n            overflow: hidden;\n        }\n        \n        .comparison-table thead {\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            color: white;\n        }\n        \n        .comparison-table th {\n            padding: 18px;\n            text-align: left;\n            font-weight: 600;\n            font-size: 1.05em;\n            color: white;\n        }\n        \n        .comparison-table td {\n            padding: 15px 18px;\n            border-bottom: 1px solid #ecf0f1;\n            color: #2c3e50;\n        }\n        \n        .comparison-table tr:last-child td {\n            border-bottom: none;\n        }\n        \n        .comparison-table tr:hover {\n            background: #f8f9fa;\n        }\n        \n        .highlight {\n            background: linear-gradient(135deg, rgba(123, 63, 242, 0.15) 0%, rgba(0, 168, 232, 0.15) 100%);\n            padding: 3px 8px;\n            border-radius: 4px;\n            font-weight: 600;\n            color: #7B3FF2;\n        }\n        \n        .card-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));\n            gap: 25px;\n            margin: 25px 0;\n        }\n        \n        .card {\n            background: white;\n            padding: 25px;\n            border-radius: 10px;\n            box-shadow: 0 4px 15px rgba(123, 63, 242, 0.1);\n            border: 2px solid #e8e8e8;\n            transition: all 0.3s ease;\n        }\n        \n        .card:hover {\n            transform: translateY(-5px);\n            box-shadow: 0 6px 20px rgba(123, 63, 242, 0.2);\n            border-color: #7B3FF2;\n        }\n        \n        .card h4 {\n            color: #7B3FF2;\n            font-size: 1.3em;\n            margin-bottom: 12px;\n        }\n        \n        .badge {\n            display: inline-block;\n            padding: 5px 12px;\n            border-radius: 20px;\n            font-size: 0.85em;\n            font-weight: 600;\n            margin: 5px 5px 5px 0;\n        }\n        \n        .badge-success {\n            background: #d4edda;\n            color: #155724;\n        }\n        \n        .badge-info {\n            background: #d1ecf1;\n            color: #0c5460;\n        }\n        \n        .badge-warning {\n            background: #fff3cd;\n            color: #856404;\n        }\n        \n        .badge-danger {\n            background: #f8d7da;\n            color: #721c24;\n        }\n        \n        .badge-primary {\n            background: linear-gradient(135deg, rgba(123, 63, 242, 0.2) 0%, rgba(0, 168, 232, 0.2) 100%);\n            color: #7B3FF2;\n        }\n        \n        ul, ol {\n            margin-left: 25px;\n            margin-top: 10px;\n        }\n        \n        li {\n            margin-bottom: 10px;\n            line-height: 1.7;\n        }\n        \n        .workflow-box {\n            background: white;\n            border: 3px solid #7B3FF2;\n            border-radius: 10px;\n            padding: 25px;\n            margin: 20px 0;\n        }\n        \n        .workflow-step {\n            display: flex;\n            align-items: center;\n            margin: 15px 0;\n            padding: 15px;\n            background: #f8f9fa;\n            border-radius: 8px;\n        }\n        \n        .step-number {\n            background: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%);\n            color: white;\n            width: 40px;\n            height: 40px;\n            border-radius: 50%;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            font-weight: bold;\n            margin-right: 20px;\n            flex-shrink: 0;\n        }\n        \n        .endpoint-box {\n            background: #1e1e1e;\n            color: #d4d4d4;\n            padding: 15px 20px;\n            border-radius: 8px;\n            margin: 15px 0;\n            font-family: 'Consolas', 'Monaco', monospace;\n            border-left: 5px solid #00A8E8;\n        }\n        \n        .method-get { border-left-color: #28a745; }\n        .method-post { border-left-color: #ffc107; }\n        .method-put { border-left-color: #17a2b8; }\n        .method-delete { border-left-color: #dc3545; }\n        \n        .method-badge {\n            display: inline-block;\n            padding: 4px 10px;\n            border-radius: 4px;\n            font-weight: bold;\n            margin-right: 10px;\n            font-size: 0.85em;\n        }\n        \n        .method-get-badge { background: #28a745; color: white; }\n        .method-post-badge { background: #ffc107; color: #000; }\n        .method-put-badge { background: #17a2b8; color: white; }\n        .method-delete-badge { background: #dc3545; color: white; }\n        \n        .status-code-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));\n            gap: 15px;\n            margin: 20px 0;\n        }\n        \n        .status-code {\n            padding: 15px;\n            border-radius: 8px;\n            border-left: 4px solid;\n        }\n        \n        .status-2xx { background: #d4edda; border-color: #28a745; }\n        .status-3xx { background: #d1ecf1; border-color: #17a2b8; }\n        .status-4xx { background: #fff3cd; border-color: #ffc107; }\n        .status-5xx { background: #f8d7da; border-color: #dc3545; }\n        \n        .best-practice {\n            background: white;\n            border: 2px solid #28a745;\n            border-radius: 8px;\n            padding: 20px;\n            margin: 15px 0;\n        }\n        \n        .best-practice::before {\n            content: \"\u2713 \";\n            color: #28a745;\n            font-weight: bold;\n            font-size: 1.3em;\n        }\n        \n        .pitfall {\n            background: white;\n            border: 2px solid #dc3545;\n            border-radius: 8px;\n            padding: 20px;\n            margin: 15px 0;\n        }\n        \n        .pitfall::before {\n            content: \"\u2717 \";\n            color: #dc3545;\n            font-weight: bold;\n            font-size: 1.3em;\n        }\n        \n        .footer {\n            margin-top: 60px;\n            padding-top: 30px;\n            border-top: 3px solid;\n            border-image: linear-gradient(135deg, #7B3FF2 0%, #00A8E8 100%) 1;\n            text-align: center;\n            color: #7B3FF2;\n            font-weight: 600;\n        }\n        \n        @media (max-width: 768px) {\n            .container {\n                padding: 20px;\n            }\n            \n            .header h1 {\n                font-size: 2em;\n            }\n            \n            .two-column {\n                grid-template-columns: 1fr;\n            }\n            \n            .comparison-table {\n                font-size: 0.9em;\n            }\n            \n            .card-grid {\n                grid-template-columns: 1fr;\n            }\n        }\n        \n        @media print {\n            .container {\n                box-shadow: none;\n            }\n            \n            .card:hover {\n                transform: none;\n            }\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"container\">\n        <div class=\"branding\">AiPro Institute<\/div>\n        <div style=\"text-align: center;\">\n            <span class=\"member-badge\">\ud83d\udd12 MEMBER EXCLUSIVE RESOURCE<\/span>\n        <\/div>\n        \n        <div class=\"header\">\n            <h1>\ud83d\udce1 API Integration Guide<\/h1>\n            <p class=\"subtitle\">Master API Integration for Business Applications<\/p>\n        <\/div>\n\n        <!-- Section 1: API Fundamentals -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83c\udfaf API Fundamentals<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>What is an API?<\/h3>\n                <p><strong>API (Application Programming Interface)<\/strong> is a set of rules and protocols that allows different software applications to communicate with each other.<\/p>\n                \n                <div class=\"info-box\">\n                    <strong>Real-World Analogy:<\/strong>\n                    Think of an API as a waiter in a restaurant:\n                    <ul>\n                        <li>You (the client) make a request from the menu<\/li>\n                        <li>The waiter (API) takes your order to the kitchen (server)<\/li>\n                        <li>The kitchen prepares your food (processes the request)<\/li>\n                        <li>The waiter brings your food back (returns the response)<\/li>\n                    <\/ul>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Key Benefits for Business<\/h4>\n                <div class=\"card-grid\">\n                    <div class=\"card\">\n                        <h4>\u26a1 Automation<\/h4>\n                        <p>Automate repetitive tasks and data synchronization between systems.<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\ud83d\udd17 Integration<\/h4>\n                        <p>Connect different tools and platforms seamlessly (CRM, payment, analytics).<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\ud83d\udcca Real-Time Data<\/h4>\n                        <p>Access live data from multiple sources instantly.<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\ud83d\udcb0 Cost Efficiency<\/h4>\n                        <p>Leverage existing services instead of building from scratch.<\/p>\n                    <\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>REST API Principles<\/h3>\n                <p><span class=\"highlight\">REST (Representational State Transfer)<\/span> is the most common API architecture used in modern web services.<\/p>\n                \n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>REST Principle<\/th>\n                            <th>Description<\/th>\n                            <th>Business Impact<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td><strong>Stateless<\/strong><\/td>\n                            <td>Each request contains all information needed<\/td>\n                            <td>Scalable, reliable systems<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Client-Server<\/strong><\/td>\n                            <td>Separation of concerns<\/td>\n                            <td>Independent development & updates<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Cacheable<\/strong><\/td>\n                            <td>Responses can be cached<\/td>\n                            <td>Faster performance, reduced costs<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Uniform Interface<\/strong><\/td>\n                            <td>Consistent API design<\/td>\n                            <td>Easier to learn and use<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Layered System<\/strong><\/td>\n                            <td>Architecture can be composed of layers<\/td>\n                            <td>Security, load balancing<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n        <\/div>\n\n        <!-- Section 2: HTTP Methods -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udd27 HTTP Methods & Operations<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>Core HTTP Methods (CRUD Operations)<\/h3>\n                \n                <div class=\"info-box\">\n                    <strong>CRUD Mapping:<\/strong> Create, Read, Update, Delete\n                <\/div>\n                \n                <div style=\"margin: 20px 0;\">\n                    <div class=\"endpoint-box method-get\">\n                        <span class=\"method-badge method-get-badge\">GET<\/span>\n                        <strong>Read\/Retrieve Data<\/strong>\n                    <\/div>\n                    <div class=\"info-box\">\n                        <strong>Use Case:<\/strong> Fetch user data, retrieve product list, get order details<br>\n                        <strong>Characteristics:<\/strong> Safe, idempotent, cacheable, no request body\n                    <\/div>\n                    <div class=\"code-block\">\n<span class=\"comment\"># Python Example: GET Request<\/span>\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Fetch user data<\/span>\nresponse = requests.<span class=\"function\">get<\/span>(<span class=\"string\">'https:\/\/api.example.com\/users\/123'<\/span>)\nuser_data = response.<span class=\"function\">json<\/span>()\n\n<span class=\"comment\"># With query parameters<\/span>\nparams = {<span class=\"string\">'page'<\/span>: <span class=\"number\">1<\/span>, <span class=\"string\">'limit'<\/span>: <span class=\"number\">10<\/span>, <span class=\"string\">'status'<\/span>: <span class=\"string\">'active'<\/span>}\nresponse = requests.<span class=\"function\">get<\/span>(<span class=\"string\">'https:\/\/api.example.com\/products'<\/span>, params=params)<\/div>\n                <\/div>\n                \n                <div style=\"margin: 30px 0;\">\n                    <div class=\"endpoint-box method-post\">\n                        <span class=\"method-badge method-post-badge\">POST<\/span>\n                        <strong>Create New Resource<\/strong>\n                    <\/div>\n                    <div class=\"info-box\">\n                        <strong>Use Case:<\/strong> Create new user, submit form, place order<br>\n                        <strong>Characteristics:<\/strong> Not safe, not idempotent, includes request body\n                    <\/div>\n                    <div class=\"code-block\">\n<span class=\"comment\"># Python Example: POST Request<\/span>\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Create new user<\/span>\nnew_user = {\n    <span class=\"string\">'name'<\/span>: <span class=\"string\">'John Doe'<\/span>,\n    <span class=\"string\">'email'<\/span>: <span class=\"string\">'<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"2d474245436d48554c405d4148034e4240\">[email&#160;protected]<\/a>'<\/span>,\n    <span class=\"string\">'role'<\/span>: <span class=\"string\">'manager'<\/span>\n}\n\nresponse = requests.<span class=\"function\">post<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/users'<\/span>,\n    json=new_user,\n    headers={<span class=\"string\">'Content-Type'<\/span>: <span class=\"string\">'application\/json'<\/span>}\n)\n\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">201<\/span>:\n    created_user = response.<span class=\"function\">json<\/span>()\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"User created with ID: {created_user['id']}\"<\/span>)<\/div>\n                <\/div>\n                \n                <div style=\"margin: 30px 0;\">\n                    <div class=\"endpoint-box method-put\">\n                        <span class=\"method-badge method-put-badge\">PUT<\/span>\n                        <strong>Update\/Replace Entire Resource<\/strong>\n                    <\/div>\n                    <div class=\"info-box\">\n                        <strong>Use Case:<\/strong> Update user profile completely, replace document<br>\n                        <strong>Characteristics:<\/strong> Not safe, idempotent, replaces entire resource\n                    <\/div>\n                    <div class=\"code-block\">\n<span class=\"comment\"># Python Example: PUT Request<\/span>\nupdated_user = {\n    <span class=\"string\">'name'<\/span>: <span class=\"string\">'John Doe Updated'<\/span>,\n    <span class=\"string\">'email'<\/span>: <span class=\"string\">'<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"eb81848385c58f848eab8e938a869b878ec5888486\">[email&#160;protected]<\/a>'<\/span>,\n    <span class=\"string\">'role'<\/span>: <span class=\"string\">'senior_manager'<\/span>,\n    <span class=\"string\">'status'<\/span>: <span class=\"string\">'active'<\/span>\n}\n\nresponse = requests.<span class=\"function\">put<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/users\/123'<\/span>,\n    json=updated_user\n)<\/div>\n                <\/div>\n                \n                <div style=\"margin: 30px 0;\">\n                    <div class=\"endpoint-box method-put\">\n                        <span class=\"method-badge method-put-badge\">PATCH<\/span>\n                        <strong>Partial Update<\/strong>\n                    <\/div>\n                    <div class=\"info-box\">\n                        <strong>Use Case:<\/strong> Update specific fields only (e.g., just email or status)<br>\n                        <strong>Characteristics:<\/strong> Not safe, partial modification\n                    <\/div>\n                    <div class=\"code-block\">\n<span class=\"comment\"># Python Example: PATCH Request<\/span>\n<span class=\"comment\"># Only update the status field<\/span>\npartial_update = {\n    <span class=\"string\">'status'<\/span>: <span class=\"string\">'inactive'<\/span>\n}\n\nresponse = requests.<span class=\"function\">patch<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/users\/123'<\/span>,\n    json=partial_update\n)<\/div>\n                <\/div>\n                \n                <div style=\"margin: 30px 0;\">\n                    <div class=\"endpoint-box method-delete\">\n                        <span class=\"method-badge method-delete-badge\">DELETE<\/span>\n                        <strong>Remove Resource<\/strong>\n                    <\/div>\n                    <div class=\"info-box\">\n                        <strong>Use Case:<\/strong> Delete user account, remove product, cancel order<br>\n                        <strong>Characteristics:<\/strong> Not safe, idempotent\n                    <\/div>\n                    <div class=\"code-block\">\n<span class=\"comment\"># Python Example: DELETE Request<\/span>\nresponse = requests.<span class=\"function\">delete<\/span>(<span class=\"string\">'https:\/\/api.example.com\/users\/123'<\/span>)\n\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">204<\/span>:\n    <span class=\"function\">print<\/span>(<span class=\"string\">\"User successfully deleted\"<\/span>)<\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Method Comparison Table<\/h3>\n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Method<\/th>\n                            <th>Purpose<\/th>\n                            <th>Idempotent?<\/th>\n                            <th>Safe?<\/th>\n                            <th>Request Body?<\/th>\n                            <th>Success Code<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td><strong>GET<\/strong><\/td>\n                            <td>Read data<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>200 OK<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>POST<\/strong><\/td>\n                            <td>Create new<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>201 Created<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>PUT<\/strong><\/td>\n                            <td>Full update<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>200 OK \/ 204 No Content<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>PATCH<\/strong><\/td>\n                            <td>Partial update<\/td>\n                            <td>~ Maybe<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>200 OK<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>DELETE<\/strong><\/td>\n                            <td>Remove<\/td>\n                            <td>\u2713 Yes<\/td>\n                            <td>\u2717 No<\/td>\n                            <td>~ Optional<\/td>\n                            <td>204 No Content<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n        <\/div>\n\n        <!-- Section 3: HTTP Status Codes -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udcca HTTP Status Codes<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>Understanding Status Codes<\/h3>\n                <p>Status codes tell you the result of your API request. They're grouped into five categories:<\/p>\n                \n                <div class=\"status-code-grid\">\n                    <div class=\"status-code status-2xx\">\n                        <strong style=\"color: #28a745; font-size: 1.2em;\">2xx - Success \u2713<\/strong>\n                        <p style=\"margin-top: 10px;\">Request was successful<\/p>\n                    <\/div>\n                    <div class=\"status-code status-3xx\">\n                        <strong style=\"color: #17a2b8; font-size: 1.2em;\">3xx - Redirection \u21aa<\/strong>\n                        <p style=\"margin-top: 10px;\">Further action needed<\/p>\n                    <\/div>\n                    <div class=\"status-code status-4xx\">\n                        <strong style=\"color: #ffc107; font-size: 1.2em;\">4xx - Client Error \u26a0<\/strong>\n                        <p style=\"margin-top: 10px;\">Problem with request<\/p>\n                    <\/div>\n                    <div class=\"status-code status-5xx\">\n                        <strong style=\"color: #dc3545; font-size: 1.2em;\">5xx - Server Error \u2717<\/strong>\n                        <p style=\"margin-top: 10px;\">Server-side problem<\/p>\n                    <\/div>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 30px;\">Common Status Codes<\/h4>\n                \n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Code<\/th>\n                            <th>Status<\/th>\n                            <th>Meaning<\/th>\n                            <th>What To Do<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr style=\"background: #d4edda;\">\n                            <td><strong>200<\/strong><\/td>\n                            <td>OK<\/td>\n                            <td>Request successful<\/td>\n                            <td>Process the response data<\/td>\n                        <\/tr>\n                        <tr style=\"background: #d4edda;\">\n                            <td><strong>201<\/strong><\/td>\n                            <td>Created<\/td>\n                            <td>Resource created successfully<\/td>\n                            <td>Use returned resource ID<\/td>\n                        <\/tr>\n                        <tr style=\"background: #d4edda;\">\n                            <td><strong>204<\/strong><\/td>\n                            <td>No Content<\/td>\n                            <td>Success, but no data to return<\/td>\n                            <td>Confirm operation completed<\/td>\n                        <\/tr>\n                        <tr style=\"background: #d1ecf1;\">\n                            <td><strong>301<\/strong><\/td>\n                            <td>Moved Permanently<\/td>\n                            <td>Resource has new URL<\/td>\n                            <td>Update your endpoint URL<\/td>\n                        <\/tr>\n                        <tr style=\"background: #d1ecf1;\">\n                            <td><strong>304<\/strong><\/td>\n                            <td>Not Modified<\/td>\n                            <td>Cached version is current<\/td>\n                            <td>Use cached data<\/td>\n                        <\/tr>\n                        <tr style=\"background: #fff3cd;\">\n                            <td><strong>400<\/strong><\/td>\n                            <td>Bad Request<\/td>\n                            <td>Invalid request format<\/td>\n                            <td>Check request syntax\/data<\/td>\n                        <\/tr>\n                        <tr style=\"background: #fff3cd;\">\n                            <td><strong>401<\/strong><\/td>\n                            <td>Unauthorized<\/td>\n                            <td>Authentication required<\/td>\n                            <td>Provide valid credentials<\/td>\n                        <\/tr>\n                        <tr style=\"background: #fff3cd;\">\n                            <td><strong>403<\/strong><\/td>\n                            <td>Forbidden<\/td>\n                            <td>No permission<\/td>\n                            <td>Check account permissions<\/td>\n                        <\/tr>\n                        <tr style=\"background: #fff3cd;\">\n                            <td><strong>404<\/strong><\/td>\n                            <td>Not Found<\/td>\n                            <td>Resource doesn't exist<\/td>\n                            <td>Verify endpoint URL\/ID<\/td>\n                        <\/tr>\n                        <tr style=\"background: #fff3cd;\">\n                            <td><strong>429<\/strong><\/td>\n                            <td>Too Many Requests<\/td>\n                            <td>Rate limit exceeded<\/td>\n                            <td>Wait and retry with backoff<\/td>\n                        <\/tr>\n                        <tr style=\"background: #f8d7da;\">\n                            <td><strong>500<\/strong><\/td>\n                            <td>Internal Server Error<\/td>\n                            <td>Server-side problem<\/td>\n                            <td>Retry later, contact support<\/td>\n                        <\/tr>\n                        <tr style=\"background: #f8d7da;\">\n                            <td><strong>503<\/strong><\/td>\n                            <td>Service Unavailable<\/td>\n                            <td>Temporary server overload<\/td>\n                            <td>Retry with exponential backoff<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Error Handling Best Practices<\/h3>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Comprehensive Error Handling<\/span>\n<span class=\"keyword\">import<\/span> requests\n<span class=\"keyword\">from<\/span> requests.exceptions <span class=\"keyword\">import<\/span> RequestException\n<span class=\"keyword\">import<\/span> time\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">make_api_request<\/span>(url, max_retries=<span class=\"number\">3<\/span>):\n    <span class=\"keyword\">for<\/span> attempt <span class=\"keyword\">in<\/span> <span class=\"function\">range<\/span>(max_retries):\n        <span class=\"keyword\">try<\/span>:\n            response = requests.<span class=\"function\">get<\/span>(url, timeout=<span class=\"number\">10<\/span>)\n            \n            <span class=\"comment\"># Handle different status codes<\/span>\n            <span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n                <span class=\"keyword\">return<\/span> response.<span class=\"function\">json<\/span>()\n            \n            <span class=\"keyword\">elif<\/span> response.status_code == <span class=\"number\">429<\/span>:\n                <span class=\"comment\"># Rate limit - wait and retry<\/span>\n                wait_time = <span class=\"number\">2<\/span> ** attempt  <span class=\"comment\"># Exponential backoff<\/span>\n                <span class=\"function\">print<\/span>(<span class=\"string\">f\"Rate limited. Waiting {wait_time}s...\"<\/span>)\n                time.<span class=\"function\">sleep<\/span>(wait_time)\n                <span class=\"keyword\">continue<\/span>\n            \n            <span class=\"keyword\">elif<\/span> response.status_code == <span class=\"number\">401<\/span>:\n                <span class=\"keyword\">raise<\/span> <span class=\"function\">Exception<\/span>(<span class=\"string\">\"Authentication failed. Check API key.\"<\/span>)\n            \n            <span class=\"keyword\">elif<\/span> response.status_code == <span class=\"number\">404<\/span>:\n                <span class=\"keyword\">raise<\/span> <span class=\"function\">Exception<\/span>(<span class=\"string\">f\"Resource not found: {url}\"<\/span>)\n            \n            <span class=\"keyword\">else<\/span>:\n                response.<span class=\"function\">raise_for_status<\/span>()\n        \n        <span class=\"keyword\">except<\/span> RequestException <span class=\"keyword\">as<\/span> e:\n            <span class=\"function\">print<\/span>(<span class=\"string\">f\"Attempt {attempt + 1} failed: {e}\"<\/span>)\n            <span class=\"keyword\">if<\/span> attempt == max_retries - <span class=\"number\">1<\/span>:\n                <span class=\"keyword\">raise<\/span>\n            time.<span class=\"function\">sleep<\/span>(<span class=\"number\">2<\/span> ** attempt)\n    \n    <span class=\"keyword\">return<\/span> <span class=\"keyword\">None<\/span>\n\n<span class=\"comment\"># Usage<\/span>\ndata = <span class=\"function\">make_api_request<\/span>(<span class=\"string\">'https:\/\/api.example.com\/data'<\/span>)<\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 4: Authentication -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udd10 API Authentication Methods<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>1. API Keys<\/h3>\n                <div class=\"info-box\">\n                    <strong>Most Common:<\/strong> Simple, widely used for public APIs<br>\n                    <strong>Security Level:<\/strong> Basic to Medium<br>\n                    <strong>Use Case:<\/strong> Third-party API access, internal tools\n                <\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: API Key in Header (Recommended)<\/span>\n<span class=\"keyword\">import<\/span> requests\n\napi_key = <span class=\"string\">\"your_api_key_here\"<\/span>\nheaders = {\n    <span class=\"string\">\"Authorization\"<\/span>: <span class=\"string\">f\"Bearer {api_key}\"<\/span>,\n    <span class=\"string\">\"Content-Type\"<\/span>: <span class=\"string\">\"application\/json\"<\/span>\n}\n\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">\"https:\/\/api.example.com\/data\"<\/span>,\n    headers=headers\n)\n\n<span class=\"comment\"># Alternative: API Key in Query Parameter (Less Secure)<\/span>\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">f\"https:\/\/api.example.com\/data?api_key={api_key}\"<\/span>\n)<\/div>\n\n                <div class=\"code-block\">\n<span class=\"comment\">\/\/ JavaScript: API Key Authentication<\/span>\n<span class=\"keyword\">const<\/span> apiKey = <span class=\"string\">'your_api_key_here'<\/span>;\n\n<span class=\"function\">fetch<\/span>(<span class=\"string\">'https:\/\/api.example.com\/data'<\/span>, {\n    method: <span class=\"string\">'GET'<\/span>,\n    headers: {\n        <span class=\"string\">'Authorization'<\/span>: <span class=\"string\">`Bearer ${apiKey}`<\/span>,\n        <span class=\"string\">'Content-Type'<\/span>: <span class=\"string\">'application\/json'<\/span>\n    }\n})\n.<span class=\"function\">then<\/span>(response => response.<span class=\"function\">json<\/span>())\n.<span class=\"function\">then<\/span>(data => <span class=\"function\">console.log<\/span>(data))\n.<span class=\"function\">catch<\/span>(error => <span class=\"function\">console.error<\/span>(<span class=\"string\">'Error:'<\/span>, error));<\/div>\n                \n                <div class=\"best-practice\">\n                    <strong>API Key Best Practices:<\/strong>\n                    <ul>\n                        <li>Store API keys in environment variables, never hardcode<\/li>\n                        <li>Use different keys for development and production<\/li>\n                        <li>Rotate keys regularly (every 90 days)<\/li>\n                        <li>Implement IP whitelisting when possible<\/li>\n                        <li>Monitor usage to detect unauthorized access<\/li>\n                    <\/ul>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>2. OAuth 2.0<\/h3>\n                <div class=\"info-box\">\n                    <strong>Most Secure:<\/strong> Industry standard for user authorization<br>\n                    <strong>Security Level:<\/strong> High<br>\n                    <strong>Use Case:<\/strong> User data access (Google, Facebook, LinkedIn APIs)\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 20px;\">OAuth 2.0 Flow<\/h4>\n                <div class=\"workflow-box\">\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">1<\/div>\n                        <div><strong>Authorization Request:<\/strong> User clicks \"Login with Google\/Facebook\"<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">2<\/div>\n                        <div><strong>User Consent:<\/strong> User approves access to their data<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">3<\/div>\n                        <div><strong>Authorization Code:<\/strong> Provider returns a temporary code<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">4<\/div>\n                        <div><strong>Token Exchange:<\/strong> Your app exchanges code for access token<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">5<\/div>\n                        <div><strong>API Access:<\/strong> Use access token to make API requests<\/div>\n                    <\/div>\n                <\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: OAuth 2.0 Example with Google API<\/span>\n<span class=\"keyword\">from<\/span> google.oauth2 <span class=\"keyword\">import<\/span> credentials\n<span class=\"keyword\">from<\/span> google_auth_oauthlib.flow <span class=\"keyword\">import<\/span> InstalledAppFlow\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Step 1: Get authorization URL<\/span>\nSCOPES = [<span class=\"string\">'https:\/\/www.googleapis.com\/auth\/userinfo.email'<\/span>]\nflow = <span class=\"function\">InstalledAppFlow.from_client_secrets_file<\/span>(\n    <span class=\"string\">'credentials.json'<\/span>, SCOPES\n)\n\n<span class=\"comment\"># Step 2: Run local server to handle callback<\/span>\ncreds = flow.<span class=\"function\">run_local_server<\/span>(port=<span class=\"number\">8080<\/span>)\n\n<span class=\"comment\"># Step 3: Use access token<\/span>\nheaders = {<span class=\"string\">'Authorization'<\/span>: <span class=\"string\">f'Bearer {creds.token}'<\/span>}\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">'https:\/\/www.googleapis.com\/oauth2\/v1\/userinfo'<\/span>,\n    headers=headers\n)\n\nuser_info = response.<span class=\"function\">json<\/span>()\n<span class=\"function\">print<\/span>(<span class=\"string\">f\"User email: {user_info['email']}\"<\/span>)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>3. JWT (JSON Web Tokens)<\/h3>\n                <div class=\"info-box\">\n                    <strong>Modern Standard:<\/strong> Self-contained, stateless authentication<br>\n                    <strong>Security Level:<\/strong> High<br>\n                    <strong>Use Case:<\/strong> Microservices, Single Sign-On (SSO)\n                <\/div>\n                \n                <p><strong>JWT Structure:<\/strong> <span class=\"highlight\">header.payload.signature<\/span><\/p>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: JWT Authentication<\/span>\n<span class=\"keyword\">import<\/span> jwt\n<span class=\"keyword\">import<\/span> datetime\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Step 1: Create JWT<\/span>\nsecret_key = <span class=\"string\">\"your_secret_key\"<\/span>\npayload = {\n    <span class=\"string\">'user_id'<\/span>: <span class=\"number\">123<\/span>,\n    <span class=\"string\">'email'<\/span>: <span class=\"string\">'<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"384d4b5d4a785d40595548545d165b5755\">[email&#160;protected]<\/a>'<\/span>,\n    <span class=\"string\">'exp'<\/span>: datetime.datetime.<span class=\"function\">utcnow<\/span>() + datetime.timedelta(hours=<span class=\"number\">1<\/span>)\n}\n\ntoken = jwt.<span class=\"function\">encode<\/span>(payload, secret_key, algorithm=<span class=\"string\">'HS256'<\/span>)\n\n<span class=\"comment\"># Step 2: Use JWT in API request<\/span>\nheaders = {<span class=\"string\">'Authorization'<\/span>: <span class=\"string\">f'Bearer {token}'<\/span>}\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/protected'<\/span>,\n    headers=headers\n)\n\n<span class=\"comment\"># Step 3: Verify JWT on server side<\/span>\n<span class=\"keyword\">try<\/span>:\n    decoded = jwt.<span class=\"function\">decode<\/span>(token, secret_key, algorithms=[<span class=\"string\">'HS256'<\/span>])\n    user_id = decoded[<span class=\"string\">'user_id'<\/span>]\n<span class=\"keyword\">except<\/span> jwt.ExpiredSignatureError:\n    <span class=\"function\">print<\/span>(<span class=\"string\">\"Token has expired\"<\/span>)\n<span class=\"keyword\">except<\/span> jwt.InvalidTokenError:\n    <span class=\"function\">print<\/span>(<span class=\"string\">\"Invalid token\"<\/span>)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>4. Basic Authentication<\/h3>\n                <div class=\"info-box\">\n                    <strong>Simplest Method:<\/strong> Username and password encoded in Base64<br>\n                    <strong>Security Level:<\/strong> Low (requires HTTPS)<br>\n                    <strong>Use Case:<\/strong> Internal tools, simple APIs with HTTPS\n                <\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Basic Authentication<\/span>\n<span class=\"keyword\">import<\/span> requests\n<span class=\"keyword\">from<\/span> requests.auth <span class=\"keyword\">import<\/span> HTTPBasicAuth\n\n<span class=\"comment\"># Method 1: Using HTTPBasicAuth<\/span>\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/data'<\/span>,\n    auth=<span class=\"function\">HTTPBasicAuth<\/span>(<span class=\"string\">'username'<\/span>, <span class=\"string\">'password'<\/span>)\n)\n\n<span class=\"comment\"># Method 2: Shorthand<\/span>\nresponse = requests.<span class=\"function\">get<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/data'<\/span>,\n    auth=(<span class=\"string\">'username'<\/span>, <span class=\"string\">'password'<\/span>)\n)<\/div>\n                \n                <div class=\"pitfall\">\n                    <strong>Security Warning:<\/strong> Never use Basic Auth over HTTP (unencrypted). Always use HTTPS to prevent credential interception.\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Authentication Method Comparison<\/h3>\n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Method<\/th>\n                            <th>Security<\/th>\n                            <th>Complexity<\/th>\n                            <th>Best For<\/th>\n                            <th>Popular Services<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td><strong>API Key<\/strong><\/td>\n                            <td>\u2b50\u2b50\u2b50<\/td>\n                            <td>Easy<\/td>\n                            <td>Public APIs, automation<\/td>\n                            <td>OpenAI, Stripe, SendGrid<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>OAuth 2.0<\/strong><\/td>\n                            <td>\u2b50\u2b50\u2b50\u2b50\u2b50<\/td>\n                            <td>Complex<\/td>\n                            <td>User data access<\/td>\n                            <td>Google, Facebook, GitHub<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>JWT<\/strong><\/td>\n                            <td>\u2b50\u2b50\u2b50\u2b50<\/td>\n                            <td>Medium<\/td>\n                            <td>Microservices, SSO<\/td>\n                            <td>Auth0, Okta, Custom APIs<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Basic Auth<\/strong><\/td>\n                            <td>\u2b50\u2b50<\/td>\n                            <td>Very Easy<\/td>\n                            <td>Internal tools, HTTPS only<\/td>\n                            <td>Legacy systems, Simple APIs<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n        <\/div>\n\n        <!-- Section 5: Request & Response Structure -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udce6 Request & Response Structure<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>API Request Anatomy<\/h3>\n                \n                <div class=\"info-box\">\n                    <strong>Complete API Request Components:<\/strong>\n                    <ol>\n                        <li><strong>Base URL:<\/strong> API server address (e.g., https:\/\/api.example.com)<\/li>\n                        <li><strong>Endpoint:<\/strong> Specific resource path (e.g., \/v1\/users\/123)<\/li>\n                        <li><strong>HTTP Method:<\/strong> Action to perform (GET, POST, etc.)<\/li>\n                        <li><strong>Headers:<\/strong> Metadata (authentication, content type)<\/li>\n                        <li><strong>Query Parameters:<\/strong> Filter\/pagination (e.g., ?page=1&limit=10)<\/li>\n                        <li><strong>Request Body:<\/strong> Data payload (for POST\/PUT\/PATCH)<\/li>\n                    <\/ol>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Complete Request Example<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Complete API Request<\/span>\n<span class=\"keyword\">import<\/span> requests\n<span class=\"keyword\">import<\/span> json\n\n<span class=\"comment\"># 1. Base URL + Endpoint<\/span>\nurl = <span class=\"string\">\"https:\/\/api.example.com\/v1\/orders\"<\/span>\n\n<span class=\"comment\"># 2. Headers (authentication, content type)<\/span>\nheaders = {\n    <span class=\"string\">\"Authorization\"<\/span>: <span class=\"string\">\"Bearer your_api_token\"<\/span>,\n    <span class=\"string\">\"Content-Type\"<\/span>: <span class=\"string\">\"application\/json\"<\/span>,\n    <span class=\"string\">\"Accept\"<\/span>: <span class=\"string\">\"application\/json\"<\/span>,\n    <span class=\"string\">\"User-Agent\"<\/span>: <span class=\"string\">\"MyApp\/1.0\"<\/span>\n}\n\n<span class=\"comment\"># 3. Query Parameters (filtering, pagination)<\/span>\nparams = {\n    <span class=\"string\">\"status\"<\/span>: <span class=\"string\">\"pending\"<\/span>,\n    <span class=\"string\">\"page\"<\/span>: <span class=\"number\">1<\/span>,\n    <span class=\"string\">\"limit\"<\/span>: <span class=\"number\">20<\/span>,\n    <span class=\"string\">\"sort\"<\/span>: <span class=\"string\">\"created_at:desc\"<\/span>\n}\n\n<span class=\"comment\"># 4. Request Body (data to send)<\/span>\ndata = {\n    <span class=\"string\">\"customer_id\"<\/span>: <span class=\"number\">12345<\/span>,\n    <span class=\"string\">\"items\"<\/span>: [\n        {<span class=\"string\">\"product_id\"<\/span>: <span class=\"number\">101<\/span>, <span class=\"string\">\"quantity\"<\/span>: <span class=\"number\">2<\/span>, <span class=\"string\">\"price\"<\/span>: <span class=\"number\">29.99<\/span>},\n        {<span class=\"string\">\"product_id\"<\/span>: <span class=\"number\">205<\/span>, <span class=\"string\">\"quantity\"<\/span>: <span class=\"number\">1<\/span>, <span class=\"string\">\"price\"<\/span>: <span class=\"number\">49.99<\/span>}\n    ],\n    <span class=\"string\">\"total\"<\/span>: <span class=\"number\">109.97<\/span>,\n    <span class=\"string\">\"currency\"<\/span>: <span class=\"string\">\"USD\"<\/span>\n}\n\n<span class=\"comment\"># 5. Make the request<\/span>\nresponse = requests.<span class=\"function\">post<\/span>(\n    url,\n    headers=headers,\n    params=params,\n    json=data,\n    timeout=<span class=\"number\">30<\/span>\n)\n\n<span class=\"comment\"># 6. Handle response<\/span>\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">201<\/span>:\n    order = response.<span class=\"function\">json<\/span>()\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"Order created: {order['id']}\"<\/span>)\n<span class=\"keyword\">else<\/span>:\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"Error: {response.status_code} - {response.text}\"<\/span>)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Common Headers<\/h3>\n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Header<\/th>\n                            <th>Purpose<\/th>\n                            <th>Example Value<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td><strong>Authorization<\/strong><\/td>\n                            <td>Authentication credentials<\/td>\n                            <td>Bearer eyJhbGc...<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Content-Type<\/strong><\/td>\n                            <td>Format of request body<\/td>\n                            <td>application\/json<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Accept<\/strong><\/td>\n                            <td>Preferred response format<\/td>\n                            <td>application\/json<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>User-Agent<\/strong><\/td>\n                            <td>Client identification<\/td>\n                            <td>MyApp\/1.0<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Accept-Language<\/strong><\/td>\n                            <td>Preferred language<\/td>\n                            <td>en-US, en;q=0.9<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Cache-Control<\/strong><\/td>\n                            <td>Caching preferences<\/td>\n                            <td>no-cache<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>API Response Structure<\/h3>\n                \n                <h4 style=\"color: #7B3FF2;\">Standard JSON Response Format<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\">\/\/ Success Response Example<\/span>\n{\n    <span class=\"string\">\"status\"<\/span>: <span class=\"string\">\"success\"<\/span>,\n    <span class=\"string\">\"code\"<\/span>: <span class=\"number\">200<\/span>,\n    <span class=\"string\">\"message\"<\/span>: <span class=\"string\">\"Data retrieved successfully\"<\/span>,\n    <span class=\"string\">\"data\"<\/span>: {\n        <span class=\"string\">\"id\"<\/span>: <span class=\"number\">12345<\/span>,\n        <span class=\"string\">\"name\"<\/span>: <span class=\"string\">\"John Doe\"<\/span>,\n        <span class=\"string\">\"email\"<\/span>: <span class=\"string\">\"<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"88e2e7e0e6c8edf0e9e5f8e4eda6ebe7e5\">[email&#160;protected]<\/a>\"<\/span>,\n        <span class=\"string\">\"created_at\"<\/span>: <span class=\"string\">\"2024-01-15T10:30:00Z\"<\/span>\n    },\n    <span class=\"string\">\"metadata\"<\/span>: {\n        <span class=\"string\">\"page\"<\/span>: <span class=\"number\">1<\/span>,\n        <span class=\"string\">\"per_page\"<\/span>: <span class=\"number\">20<\/span>,\n        <span class=\"string\">\"total\"<\/span>: <span class=\"number\">150<\/span>\n    }\n}<\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\">\/\/ Error Response Example<\/span>\n{\n    <span class=\"string\">\"status\"<\/span>: <span class=\"string\">\"error\"<\/span>,\n    <span class=\"string\">\"code\"<\/span>: <span class=\"number\">400<\/span>,\n    <span class=\"string\">\"message\"<\/span>: <span class=\"string\">\"Validation failed\"<\/span>,\n    <span class=\"string\">\"errors\"<\/span>: [\n        {\n            <span class=\"string\">\"field\"<\/span>: <span class=\"string\">\"email\"<\/span>,\n            <span class=\"string\">\"message\"<\/span>: <span class=\"string\">\"Invalid email format\"<\/span>\n        },\n        {\n            <span class=\"string\">\"field\"<\/span>: <span class=\"string\">\"age\"<\/span>,\n            <span class=\"string\">\"message\"<\/span>: <span class=\"string\">\"Must be at least 18\"<\/span>\n        }\n    ],\n    <span class=\"string\">\"request_id\"<\/span>: <span class=\"string\">\"req_abc123xyz\"<\/span>,\n    <span class=\"string\">\"timestamp\"<\/span>: <span class=\"string\">\"2024-01-15T10:30:00Z\"<\/span>\n}<\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Parsing JSON Response<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Parse and Handle Response<\/span>\n<span class=\"keyword\">import<\/span> requests\n\nresponse = requests.<span class=\"function\">get<\/span>(<span class=\"string\">'https:\/\/api.example.com\/users\/123'<\/span>)\n\n<span class=\"comment\"># Check if request was successful<\/span>\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n    <span class=\"comment\"># Parse JSON response<\/span>\n    data = response.<span class=\"function\">json<\/span>()\n    \n    <span class=\"comment\"># Access nested data<\/span>\n    user_name = data[<span class=\"string\">'data'<\/span>][<span class=\"string\">'name'<\/span>]\n    user_email = data[<span class=\"string\">'data'<\/span>][<span class=\"string\">'email'<\/span>]\n    \n    <span class=\"comment\"># Safe access with .get() method<\/span>\n    user_phone = data.<span class=\"function\">get<\/span>(<span class=\"string\">'data'<\/span>, {}).<span class=\"function\">get<\/span>(<span class=\"string\">'phone'<\/span>, <span class=\"string\">'N\/A'<\/span>)\n    \n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"Name: {user_name}, Email: {user_email}\"<\/span>)\n<span class=\"keyword\">else<\/span>:\n    <span class=\"comment\"># Handle error response<\/span>\n    error_data = response.<span class=\"function\">json<\/span>()\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"Error: {error_data['message']}\"<\/span>)\n    \n    <span class=\"comment\"># Print validation errors if available<\/span>\n    <span class=\"keyword\">if<\/span> <span class=\"string\">'errors'<\/span> <span class=\"keyword\">in<\/span> error_data:\n        <span class=\"keyword\">for<\/span> error <span class=\"keyword\">in<\/span> error_data[<span class=\"string\">'errors'<\/span>]:\n            <span class=\"function\">print<\/span>(<span class=\"string\">f\"  - {error['field']}: {error['message']}\"<\/span>)<\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 6: Rate Limiting & Best Practices -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\u26a1 Rate Limiting & Performance<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>Understanding Rate Limits<\/h3>\n                <div class=\"info-box\">\n                    <strong>What is Rate Limiting?<\/strong><br>\n                    Rate limiting restricts the number of API requests you can make within a time period (e.g., 100 requests per minute). This prevents abuse and ensures fair usage.\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 20px;\">Common Rate Limit Headers<\/h4>\n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Header<\/th>\n                            <th>Meaning<\/th>\n                            <th>Example Value<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td><strong>X-RateLimit-Limit<\/strong><\/td>\n                            <td>Maximum requests allowed<\/td>\n                            <td>1000<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>X-RateLimit-Remaining<\/strong><\/td>\n                            <td>Requests left in current window<\/td>\n                            <td>750<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>X-RateLimit-Reset<\/strong><\/td>\n                            <td>When limit resets (Unix timestamp)<\/td>\n                            <td>1705320000<\/td>\n                        <\/tr>\n                        <tr>\n                            <td><strong>Retry-After<\/strong><\/td>\n                            <td>Seconds to wait before retry<\/td>\n                            <td>60<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Handling Rate Limits<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Rate Limit Handling with Exponential Backoff<\/span>\n<span class=\"keyword\">import<\/span> requests\n<span class=\"keyword\">import<\/span> time\n<span class=\"keyword\">from<\/span> datetime <span class=\"keyword\">import<\/span> datetime\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">make_request_with_retry<\/span>(url, max_retries=<span class=\"number\">5<\/span>):\n    <span class=\"keyword\">for<\/span> attempt <span class=\"keyword\">in<\/span> <span class=\"function\">range<\/span>(max_retries):\n        response = requests.<span class=\"function\">get<\/span>(url)\n        \n        <span class=\"comment\"># Check rate limit headers<\/span>\n        remaining = <span class=\"function\">int<\/span>(response.headers.<span class=\"function\">get<\/span>(<span class=\"string\">'X-RateLimit-Remaining'<\/span>, <span class=\"number\">999<\/span>))\n        \n        <span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n            <span class=\"comment\"># Warn if approaching limit<\/span>\n            <span class=\"keyword\">if<\/span> remaining < <span class=\"number\">10<\/span>:\n                <span class=\"function\">print<\/span>(<span class=\"string\">f\"Warning: Only {remaining} requests remaining\"<\/span>)\n            <span class=\"keyword\">return<\/span> response.<span class=\"function\">json<\/span>()\n        \n        <span class=\"keyword\">elif<\/span> response.status_code == <span class=\"number\">429<\/span>:\n            <span class=\"comment\"># Rate limit exceeded<\/span>\n            retry_after = <span class=\"function\">int<\/span>(response.headers.<span class=\"function\">get<\/span>(<span class=\"string\">'Retry-After'<\/span>, <span class=\"number\">60<\/span>))\n            \n            <span class=\"keyword\">if<\/span> attempt < max_retries - <span class=\"number\">1<\/span>:\n                <span class=\"function\">print<\/span>(<span class=\"string\">f\"Rate limited. Waiting {retry_after}s...\"<\/span>)\n                time.<span class=\"function\">sleep<\/span>(retry_after)\n            <span class=\"keyword\">else<\/span>:\n                <span class=\"keyword\">raise<\/span> <span class=\"function\">Exception<\/span>(<span class=\"string\">\"Max retries exceeded\"<\/span>)\n        <span class=\"keyword\">else<\/span>:\n            response.<span class=\"function\">raise_for_status<\/span>()\n    \n    <span class=\"keyword\">return<\/span> <span class=\"keyword\">None<\/span>\n\n<span class=\"comment\"># Usage with rate limit monitoring<\/span>\n<span class=\"keyword\">def<\/span> <span class=\"function\">batch_requests<\/span>(urls):\n    results = []\n    <span class=\"keyword\">for<\/span> url <span class=\"keyword\">in<\/span> urls:\n        result = <span class=\"function\">make_request_with_retry<\/span>(url)\n        results.<span class=\"function\">append<\/span>(result)\n        <span class=\"comment\"># Add small delay between requests<\/span>\n        time.<span class=\"function\">sleep<\/span>(<span class=\"number\">0.1<\/span>)\n    <span class=\"keyword\">return<\/span> results<\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Exponential Backoff Strategy<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Exponential Backoff Implementation<\/span>\n<span class=\"keyword\">import<\/span> time\n<span class=\"keyword\">import<\/span> random\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">exponential_backoff<\/span>(attempt, base_delay=<span class=\"number\">1<\/span>, max_delay=<span class=\"number\">60<\/span>):\n    <span class=\"string\">\"\"\"Calculate wait time with exponential backoff and jitter\"\"\"<\/span>\n    delay = <span class=\"function\">min<\/span>(base_delay * (<span class=\"number\">2<\/span> ** attempt), max_delay)\n    jitter = random.<span class=\"function\">uniform<\/span>(<span class=\"number\">0<\/span>, delay * <span class=\"number\">0.1<\/span>)  <span class=\"comment\"># Add randomness<\/span>\n    <span class=\"keyword\">return<\/span> delay + jitter\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">resilient_api_call<\/span>(url, max_attempts=<span class=\"number\">5<\/span>):\n    <span class=\"keyword\">for<\/span> attempt <span class=\"keyword\">in<\/span> <span class=\"function\">range<\/span>(max_attempts):\n        <span class=\"keyword\">try<\/span>:\n            response = requests.<span class=\"function\">get<\/span>(url, timeout=<span class=\"number\">10<\/span>)\n            \n            <span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n                <span class=\"keyword\">return<\/span> response.<span class=\"function\">json<\/span>()\n            \n            <span class=\"keyword\">elif<\/span> response.status_code <span class=\"keyword\">in<\/span> [<span class=\"number\">429<\/span>, <span class=\"number\">503<\/span>]:\n                wait_time = <span class=\"function\">exponential_backoff<\/span>(attempt)\n                <span class=\"function\">print<\/span>(<span class=\"string\">f\"Attempt {attempt + 1}: Waiting {wait_time:.2f}s\"<\/span>)\n                time.<span class=\"function\">sleep<\/span>(wait_time)\n            <span class=\"keyword\">else<\/span>:\n                response.<span class=\"function\">raise_for_status<\/span>()\n        \n        <span class=\"keyword\">except<\/span> requests.RequestException <span class=\"keyword\">as<\/span> e:\n            <span class=\"keyword\">if<\/span> attempt == max_attempts - <span class=\"number\">1<\/span>:\n                <span class=\"keyword\">raise<\/span>\n            wait_time = <span class=\"function\">exponential_backoff<\/span>(attempt)\n            time.<span class=\"function\">sleep<\/span>(wait_time)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>API Integration Best Practices<\/h3>\n                \n                <div class=\"two-column\">\n                    <div>\n                        <div class=\"best-practice\">\n                            <strong>DO's:<\/strong>\n                            <ul>\n                                <li>Use HTTPS for all API calls<\/li>\n                                <li>Implement retry logic with exponential backoff<\/li>\n                                <li>Cache responses when appropriate<\/li>\n                                <li>Set reasonable timeout values<\/li>\n                                <li>Log all API errors with context<\/li>\n                                <li>Validate data before sending<\/li>\n                                <li>Use pagination for large datasets<\/li>\n                                <li>Monitor API usage and costs<\/li>\n                            <\/ul>\n                        <\/div>\n                    <\/div>\n                    <div>\n                        <div class=\"pitfall\">\n                            <strong>DON'Ts:<\/strong>\n                            <ul>\n                                <li>Hardcode API keys in code<\/li>\n                                <li>Ignore rate limiting<\/li>\n                                <li>Make synchronous calls in loops<\/li>\n                                <li>Skip error handling<\/li>\n                                <li>Request more data than needed<\/li>\n                                <li>Forget to implement timeouts<\/li>\n                                <li>Expose API keys in client-side code<\/li>\n                                <li>Skip API version checking<\/li>\n                            <\/ul>\n                        <\/div>\n                    <\/div>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 30px;\">Performance Optimization Techniques<\/h4>\n                \n                <div class=\"card-grid\">\n                    <div class=\"card\">\n                        <h4>\ud83d\udd04 Batch Requests<\/h4>\n                        <p>Combine multiple operations into single API call when supported. Reduces network overhead and improves throughput.<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\ud83d\udcbe Response Caching<\/h4>\n                        <p>Cache API responses for frequently accessed data. Use cache headers to determine freshness.<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\u26a1 Async\/Parallel Requests<\/h4>\n                        <p>Make multiple API calls concurrently for independent requests. Significantly reduces total execution time.<\/p>\n                    <\/div>\n                    <div class=\"card\">\n                        <h4>\ud83d\udcc9 Pagination<\/h4>\n                        <p>Request data in chunks instead of all at once. Improves response time and memory usage.<\/p>\n                    <\/div>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Async API Requests (Python)<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Async API Calls for Better Performance<\/span>\n<span class=\"keyword\">import<\/span> asyncio\n<span class=\"keyword\">import<\/span> aiohttp\n\n<span class=\"keyword\">async<\/span> <span class=\"keyword\">def<\/span> <span class=\"function\">fetch_data<\/span>(session, url):\n    <span class=\"keyword\">async<\/span> <span class=\"keyword\">with<\/span> session.<span class=\"function\">get<\/span>(url) <span class=\"keyword\">as<\/span> response:\n        <span class=\"keyword\">return<\/span> <span class=\"keyword\">await<\/span> response.<span class=\"function\">json<\/span>()\n\n<span class=\"keyword\">async<\/span> <span class=\"keyword\">def<\/span> <span class=\"function\">fetch_all<\/span>(urls):\n    <span class=\"keyword\">async<\/span> <span class=\"keyword\">with<\/span> aiohttp.<span class=\"function\">ClientSession<\/span>() <span class=\"keyword\">as<\/span> session:\n        <span class=\"comment\"># Create tasks for all URLs<\/span>\n        tasks = [<span class=\"function\">fetch_data<\/span>(session, url) <span class=\"keyword\">for<\/span> url <span class=\"keyword\">in<\/span> urls]\n        <span class=\"comment\"># Execute all tasks concurrently<\/span>\n        results = <span class=\"keyword\">await<\/span> asyncio.<span class=\"function\">gather<\/span>(*tasks)\n        <span class=\"keyword\">return<\/span> results\n\n<span class=\"comment\"># Usage: Fetch 10 endpoints concurrently<\/span>\nurls = [<span class=\"string\">f'https:\/\/api.example.com\/users\/{i}'<\/span> <span class=\"keyword\">for<\/span> i <span class=\"keyword\">in<\/span> <span class=\"function\">range<\/span>(<span class=\"number\">1<\/span>, <span class=\"number\">11<\/span>)]\nresults = asyncio.<span class=\"function\">run<\/span>(<span class=\"function\">fetch_all<\/span>(urls))\n\n<span class=\"comment\"># This is much faster than sequential requests!<\/span><\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 7: Common API Patterns -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83c\udfa8 Common API Patterns<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>1. Pagination<\/h3>\n                <div class=\"info-box\">\n                    <strong>Why Pagination?<\/strong> Breaking large result sets into smaller pages improves performance and user experience.\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 20px;\">Pagination Methods<\/h4>\n                \n                <div class=\"card-grid\">\n                    <div class=\"card\">\n                        <h4>Offset-Based Pagination<\/h4>\n                        <div class=\"code-block\" style=\"margin-top: 10px; font-size: 0.85em;\">\nGET \/users?offset=20&limit=10\n<span class=\"comment\"># Skip 20, return next 10<\/span><\/div>\n                        <span class=\"badge badge-success\" style=\"margin-top: 10px;\">Simple<\/span>\n                        <span class=\"badge badge-warning\">Can miss items<\/span>\n                    <\/div>\n                    \n                    <div class=\"card\">\n                        <h4>Page-Based Pagination<\/h4>\n                        <div class=\"code-block\" style=\"margin-top: 10px; font-size: 0.85em;\">\nGET \/users?page=3&per_page=10\n<span class=\"comment\"># Get page 3 (items 21-30)<\/span><\/div>\n                        <span class=\"badge badge-success\" style=\"margin-top: 10px;\">User-friendly<\/span>\n                        <span class=\"badge badge-info\">Most common<\/span>\n                    <\/div>\n                    \n                    <div class=\"card\">\n                        <h4>Cursor-Based Pagination<\/h4>\n                        <div class=\"code-block\" style=\"margin-top: 10px; font-size: 0.85em;\">\nGET \/users?cursor=abc123&limit=10\n<span class=\"comment\"># Continue from cursor<\/span><\/div>\n                        <span class=\"badge badge-success\" style=\"margin-top: 10px;\">Consistent<\/span>\n                        <span class=\"badge badge-primary\">Best for real-time<\/span>\n                    <\/div>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Pagination Implementation<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Paginate Through All Results<\/span>\n<span class=\"keyword\">def<\/span> <span class=\"function\">fetch_all_users<\/span>(base_url):\n    all_users = []\n    page = <span class=\"number\">1<\/span>\n    per_page = <span class=\"number\">100<\/span>\n    \n    <span class=\"keyword\">while<\/span> <span class=\"keyword\">True<\/span>:\n        response = requests.<span class=\"function\">get<\/span>(\n            base_url,\n            params={<span class=\"string\">'page'<\/span>: page, <span class=\"string\">'per_page'<\/span>: per_page}\n        )\n        data = response.<span class=\"function\">json<\/span>()\n        \n        users = data[<span class=\"string\">'data'<\/span>]\n        all_users.<span class=\"function\">extend<\/span>(users)\n        \n        <span class=\"function\">print<\/span>(<span class=\"string\">f\"Fetched page {page}: {len(users)} users\"<\/span>)\n        \n        <span class=\"comment\"># Check if there are more pages<\/span>\n        <span class=\"keyword\">if<\/span> <span class=\"function\">len<\/span>(users) < per_page <span class=\"keyword\">or<\/span> data[<span class=\"string\">'metadata'<\/span>][<span class=\"string\">'has_more'<\/span>] == <span class=\"keyword\">False<\/span>:\n            <span class=\"keyword\">break<\/span>\n        \n        page += <span class=\"number\">1<\/span>\n    \n    <span class=\"keyword\">return<\/span> all_users\n\n<span class=\"comment\"># Usage<\/span>\nusers = <span class=\"function\">fetch_all_users<\/span>(<span class=\"string\">'https:\/\/api.example.com\/users'<\/span>)\n<span class=\"function\">print<\/span>(<span class=\"string\">f\"Total users fetched: {len(users)}\"<\/span>)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>2. Filtering & Sorting<\/h3>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Filtering Examples<\/span>\nGET \/products?category=electronics&status=active&price_min=100&price_max=500\n\n<span class=\"comment\"># Sorting Examples<\/span>\nGET \/products?sort=price:asc        <span class=\"comment\"># Sort by price ascending<\/span>\nGET \/products?sort=-created_at      <span class=\"comment\"># Sort by date descending (- prefix)<\/span>\nGET \/products?sort=category,price   <span class=\"comment\"># Multi-field sort<\/span>\n\n<span class=\"comment\"># Search<\/span>\nGET \/products?q=laptop&search_fields=name,description<\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Advanced Filtering<\/span>\nparams = {\n    <span class=\"comment\"># Filtering<\/span>\n    <span class=\"string\">'status'<\/span>: <span class=\"string\">'active'<\/span>,\n    <span class=\"string\">'category'<\/span>: <span class=\"string\">'electronics'<\/span>,\n    <span class=\"string\">'price_min'<\/span>: <span class=\"number\">100<\/span>,\n    <span class=\"string\">'price_max'<\/span>: <span class=\"number\">500<\/span>,\n    <span class=\"string\">'brand'<\/span>: [<span class=\"string\">'Apple'<\/span>, <span class=\"string\">'Samsung'<\/span>],  <span class=\"comment\"># Multiple values<\/span>\n    \n    <span class=\"comment\"># Sorting<\/span>\n    <span class=\"string\">'sort'<\/span>: <span class=\"string\">'-popularity,price'<\/span>,  <span class=\"comment\"># Multi-field<\/span>\n    \n    <span class=\"comment\"># Pagination<\/span>\n    <span class=\"string\">'page'<\/span>: <span class=\"number\">1<\/span>,\n    <span class=\"string\">'per_page'<\/span>: <span class=\"number\">20<\/span>,\n    \n    <span class=\"comment\"># Field selection<\/span>\n    <span class=\"string\">'fields'<\/span>: <span class=\"string\">'id,name,price,image'<\/span>  <span class=\"comment\"># Only return specific fields<\/span>\n}\n\nresponse = requests.<span class=\"function\">get<\/span>(<span class=\"string\">'https:\/\/api.example.com\/products'<\/span>, params=params)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>3. Webhooks<\/h3>\n                <div class=\"info-box\">\n                    <strong>What are Webhooks?<\/strong><br>\n                    Instead of your app repeatedly asking \"anything new?\" (polling), webhooks let external services notify your app when events occur.\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 20px;\">Webhook Flow<\/h4>\n                <div class=\"workflow-box\">\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">1<\/div>\n                        <div><strong>Register:<\/strong> Provide your webhook URL to the service<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">2<\/div>\n                        <div><strong>Event Occurs:<\/strong> Something happens (payment, new order, etc.)<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">3<\/div>\n                        <div><strong>Service Notifies:<\/strong> Service sends POST request to your URL<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">4<\/div>\n                        <div><strong>Process:<\/strong> Your app processes the event data<\/div>\n                    <\/div>\n                    <div class=\"workflow-step\">\n                        <div class=\"step-number\">5<\/div>\n                        <div><strong>Respond:<\/strong> Return 200 OK to acknowledge receipt<\/div>\n                    <\/div>\n                <\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python Flask: Simple Webhook Receiver<\/span>\n<span class=\"keyword\">from<\/span> flask <span class=\"keyword\">import<\/span> Flask, request, jsonify\n<span class=\"keyword\">import<\/span> hmac\n<span class=\"keyword\">import<\/span> hashlib\n\napp = <span class=\"function\">Flask<\/span>(__name__)\nWEBHOOK_SECRET = <span class=\"string\">\"your_webhook_secret\"<\/span>\n\n<span class=\"keyword\">@app.route<\/span>(<span class=\"string\">'\/webhook\/stripe'<\/span>, methods=[<span class=\"string\">'POST'<\/span>])\n<span class=\"keyword\">def<\/span> <span class=\"function\">stripe_webhook<\/span>():\n    <span class=\"comment\"># 1. Verify webhook signature<\/span>\n    signature = request.headers.<span class=\"function\">get<\/span>(<span class=\"string\">'Stripe-Signature'<\/span>)\n    <span class=\"keyword\">if<\/span> <span class=\"keyword\">not<\/span> <span class=\"function\">verify_signature<\/span>(request.data, signature):\n        <span class=\"keyword\">return<\/span> <span class=\"function\">jsonify<\/span>({<span class=\"string\">'error'<\/span>: <span class=\"string\">'Invalid signature'<\/span>}), <span class=\"number\">403<\/span>\n    \n    <span class=\"comment\"># 2. Parse webhook payload<\/span>\n    event = request.<span class=\"function\">get_json<\/span>()\n    event_type = event[<span class=\"string\">'type'<\/span>]\n    \n    <span class=\"comment\"># 3. Handle different event types<\/span>\n    <span class=\"keyword\">if<\/span> event_type == <span class=\"string\">'payment_intent.succeeded'<\/span>:\n        payment = event[<span class=\"string\">'data'<\/span>][<span class=\"string\">'object'<\/span>]\n        <span class=\"function\">handle_successful_payment<\/span>(payment)\n    \n    <span class=\"keyword\">elif<\/span> event_type == <span class=\"string\">'payment_intent.failed'<\/span>:\n        payment = event[<span class=\"string\">'data'<\/span>][<span class=\"string\">'object'<\/span>]\n        <span class=\"function\">handle_failed_payment<\/span>(payment)\n    \n    <span class=\"comment\"># 4. Return success response<\/span>\n    <span class=\"keyword\">return<\/span> <span class=\"function\">jsonify<\/span>({<span class=\"string\">'status'<\/span>: <span class=\"string\">'success'<\/span>}), <span class=\"number\">200<\/span>\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">verify_signature<\/span>(payload, signature):\n    computed = hmac.<span class=\"function\">new<\/span>(\n        WEBHOOK_SECRET.<span class=\"function\">encode<\/span>(),\n        payload,\n        hashlib.sha256\n    ).<span class=\"function\">hexdigest<\/span>()\n    <span class=\"keyword\">return<\/span> hmac.<span class=\"function\">compare_digest<\/span>(computed, signature)<\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>4. File Upload\/Download<\/h3>\n                \n                <h4 style=\"color: #7B3FF2;\">Upload File to API<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: File Upload<\/span>\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Upload single file<\/span>\n<span class=\"keyword\">with<\/span> <span class=\"function\">open<\/span>(<span class=\"string\">'document.pdf'<\/span>, <span class=\"string\">'rb'<\/span>) <span class=\"keyword\">as<\/span> file:\n    files = {<span class=\"string\">'file'<\/span>: file}\n    data = {\n        <span class=\"string\">'title'<\/span>: <span class=\"string\">'Annual Report'<\/span>,\n        <span class=\"string\">'category'<\/span>: <span class=\"string\">'financial'<\/span>\n    }\n    response = requests.<span class=\"function\">post<\/span>(\n        <span class=\"string\">'https:\/\/api.example.com\/upload'<\/span>,\n        files=files,\n        data=data\n    )\n\n<span class=\"comment\"># Upload multiple files<\/span>\nfiles = [\n    (<span class=\"string\">'files'<\/span>, <span class=\"function\">open<\/span>(<span class=\"string\">'doc1.pdf'<\/span>, <span class=\"string\">'rb'<\/span>)),\n    (<span class=\"string\">'files'<\/span>, <span class=\"function\">open<\/span>(<span class=\"string\">'doc2.pdf'<\/span>, <span class=\"string\">'rb'<\/span>))\n]\nresponse = requests.<span class=\"function\">post<\/span>(<span class=\"string\">'https:\/\/api.example.com\/upload'<\/span>, files=files)<\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Download File from API<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># Python: File Download<\/span>\nresponse = requests.<span class=\"function\">get<\/span>(<span class=\"string\">'https:\/\/api.example.com\/download\/report.pdf'<\/span>, stream=<span class=\"keyword\">True<\/span>)\n\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n    <span class=\"keyword\">with<\/span> <span class=\"function\">open<\/span>(<span class=\"string\">'downloaded_report.pdf'<\/span>, <span class=\"string\">'wb'<\/span>) <span class=\"keyword\">as<\/span> file:\n        <span class=\"keyword\">for<\/span> chunk <span class=\"keyword\">in<\/span> response.<span class=\"function\">iter_content<\/span>(chunk_size=<span class=\"number\">8192<\/span>):\n            file.<span class=\"function\">write<\/span>(chunk)\n    <span class=\"function\">print<\/span>(<span class=\"string\">\"File downloaded successfully\"<\/span>)\n\n<span class=\"comment\"># Get filename from response headers<\/span>\ncontent_disposition = response.headers.<span class=\"function\">get<\/span>(<span class=\"string\">'Content-Disposition'<\/span>)\n<span class=\"keyword\">if<\/span> content_disposition:\n    filename = content_disposition.<span class=\"function\">split<\/span>(<span class=\"string\">'filename='<\/span>)[<span class=\"number\">1<\/span>].<span class=\"function\">strip<\/span>(<span class=\"string\">'\"'<\/span>)<\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 8: Business Use Cases -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udcbc Business Use Cases<\/h2>\n            \n            <div class=\"card-grid\">\n                <div class=\"card\">\n                    <h4>\ud83d\uded2 E-Commerce Integration<\/h4>\n                    <p><strong>APIs Used:<\/strong> Stripe, PayPal, Shopify<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Process payments securely<\/li>\n                        <li>Manage inventory in real-time<\/li>\n                        <li>Track shipments automatically<\/li>\n                        <li>Sync orders across platforms<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-primary\">ROI: 40% faster checkout<\/span>\n                <\/div>\n                \n                <div class=\"card\">\n                    <h4>\ud83d\udcca CRM Automation<\/h4>\n                    <p><strong>APIs Used:<\/strong> Salesforce, HubSpot, Pipedrive<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Auto-create leads from forms<\/li>\n                        <li>Sync contacts between systems<\/li>\n                        <li>Trigger email campaigns<\/li>\n                        <li>Generate sales reports<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-success\">ROI: 60% time saved<\/span>\n                <\/div>\n                \n                <div class=\"card\">\n                    <h4>\ud83d\udce7 Email Marketing<\/h4>\n                    <p><strong>APIs Used:<\/strong> Mailchimp, SendGrid, Twilio<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Send personalized campaigns<\/li>\n                        <li>Track email open\/click rates<\/li>\n                        <li>Manage subscriber lists<\/li>\n                        <li>Automate follow-ups<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-info\">ROI: 3x engagement<\/span>\n                <\/div>\n                \n                <div class=\"card\">\n                    <h4>\ud83d\udcc5 Calendar Scheduling<\/h4>\n                    <p><strong>APIs Used:<\/strong> Google Calendar, Calendly, Zoom<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Book meetings automatically<\/li>\n                        <li>Send calendar invitations<\/li>\n                        <li>Create video conference links<\/li>\n                        <li>Sync across team calendars<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-warning\">ROI: 50% fewer no-shows<\/span>\n                <\/div>\n                \n                <div class=\"card\">\n                    <h4>\ud83d\udcac Customer Support<\/h4>\n                    <p><strong>APIs Used:<\/strong> Zendesk, Intercom, Slack<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Create support tickets<\/li>\n                        <li>Route inquiries automatically<\/li>\n                        <li>Send automated responses<\/li>\n                        <li>Track resolution time<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-success\">ROI: 70% faster resolution<\/span>\n                <\/div>\n                \n                <div class=\"card\">\n                    <h4>\ud83d\udcca Analytics & Reporting<\/h4>\n                    <p><strong>APIs Used:<\/strong> Google Analytics, Mixpanel, Tableau<\/p>\n                    <ul style=\"margin-top: 10px;\">\n                        <li>Pull analytics data<\/li>\n                        <li>Generate custom reports<\/li>\n                        <li>Track KPIs in real-time<\/li>\n                        <li>Visualize business metrics<\/li>\n                    <\/ul>\n                    <span class=\"badge badge-primary\">ROI: Data-driven decisions<\/span>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\" style=\"margin-top: 40px;\">\n                <h3>Complete Business Integration Example<\/h3>\n                <div class=\"info-box\">\n                    <strong>Scenario:<\/strong> Automate lead generation workflow<br>\n                    When someone fills out a contact form, automatically create a CRM lead, send a welcome email, and notify the sales team on Slack.\n                <\/div>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Complete Business Workflow Integration<\/span>\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"keyword\">class<\/span> <span class=\"function\">LeadAutomation<\/span>:\n    <span class=\"keyword\">def<\/span> <span class=\"function\">__init__<\/span>(<span class=\"keyword\">self<\/span>):\n        <span class=\"keyword\">self<\/span>.salesforce_api = <span class=\"string\">\"your_salesforce_token\"<\/span>\n        <span class=\"keyword\">self<\/span>.sendgrid_api = <span class=\"string\">\"your_sendgrid_key\"<\/span>\n        <span class=\"keyword\">self<\/span>.slack_webhook = <span class=\"string\">\"your_slack_webhook_url\"<\/span>\n    \n    <span class=\"keyword\">def<\/span> <span class=\"function\">process_form_submission<\/span>(<span class=\"keyword\">self<\/span>, form_data):\n        <span class=\"string\">\"\"\"Complete workflow for new lead\"\"\"<\/span>\n        \n        <span class=\"comment\"># Step 1: Create lead in Salesforce CRM<\/span>\n        lead_id = <span class=\"keyword\">self<\/span>.<span class=\"function\">create_crm_lead<\/span>(form_data)\n        \n        <span class=\"comment\"># Step 2: Send welcome email via SendGrid<\/span>\n        email_sent = <span class=\"keyword\">self<\/span>.<span class=\"function\">send_welcome_email<\/span>(form_data[<span class=\"string\">'email'<\/span>])\n        \n        <span class=\"comment\"># Step 3: Notify sales team on Slack<\/span>\n        <span class=\"keyword\">self<\/span>.<span class=\"function\">notify_sales_team<\/span>(form_data, lead_id)\n        \n        <span class=\"keyword\">return<\/span> {\n            <span class=\"string\">'lead_id'<\/span>: lead_id,\n            <span class=\"string\">'email_sent'<\/span>: email_sent,\n            <span class=\"string\">'status'<\/span>: <span class=\"string\">'success'<\/span>\n        }\n    \n    <span class=\"keyword\">def<\/span> <span class=\"function\">create_crm_lead<\/span>(<span class=\"keyword\">self<\/span>, data):\n        <span class=\"string\">\"\"\"Create lead in Salesforce\"\"\"<\/span>\n        url = <span class=\"string\">\"https:\/\/api.salesforce.com\/services\/data\/v52.0\/sobjects\/Lead\"<\/span>\n        headers = {\n            <span class=\"string\">\"Authorization\"<\/span>: <span class=\"string\">f\"Bearer {self.salesforce_api}\"<\/span>,\n            <span class=\"string\">\"Content-Type\"<\/span>: <span class=\"string\">\"application\/json\"<\/span>\n        }\n        payload = {\n            <span class=\"string\">\"FirstName\"<\/span>: data[<span class=\"string\">'first_name'<\/span>],\n            <span class=\"string\">\"LastName\"<\/span>: data[<span class=\"string\">'last_name'<\/span>],\n            <span class=\"string\">\"Email\"<\/span>: data[<span class=\"string\">'email'<\/span>],\n            <span class=\"string\">\"Company\"<\/span>: data[<span class=\"string\">'company'<\/span>],\n            <span class=\"string\">\"Status\"<\/span>: <span class=\"string\">\"New\"<\/span>,\n            <span class=\"string\">\"LeadSource\"<\/span>: <span class=\"string\">\"Website\"<\/span>\n        }\n        response = requests.<span class=\"function\">post<\/span>(url, json=payload, headers=headers)\n        <span class=\"keyword\">return<\/span> response.<span class=\"function\">json<\/span>()[<span class=\"string\">'id'<\/span>]\n    \n    <span class=\"keyword\">def<\/span> <span class=\"function\">send_welcome_email<\/span>(<span class=\"keyword\">self<\/span>, email):\n        <span class=\"string\">\"\"\"Send email via SendGrid\"\"\"<\/span>\n        url = <span class=\"string\">\"https:\/\/api.sendgrid.com\/v3\/mail\/send\"<\/span>\n        headers = {\n            <span class=\"string\">\"Authorization\"<\/span>: <span class=\"string\">f\"Bearer {self.sendgrid_api}\"<\/span>,\n            <span class=\"string\">\"Content-Type\"<\/span>: <span class=\"string\">\"application\/json\"<\/span>\n        }\n        payload = {\n            <span class=\"string\">\"personalizations\"<\/span>: [{<span class=\"string\">\"to\"<\/span>: [{<span class=\"string\">\"email\"<\/span>: email}]}],\n            <span class=\"string\">\"from\"<\/span>: {<span class=\"string\">\"email\"<\/span>: <span class=\"string\">\"<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"8bf8eae7eef8cbe8e4e6fbeae5f2a5e8e4e6\">[email&#160;protected]<\/a>\"<\/span>},\n            <span class=\"string\">\"subject\"<\/span>: <span class=\"string\">\"Welcome! Let's get started\"<\/span>,\n            <span class=\"string\">\"content\"<\/span>: [{\n                <span class=\"string\">\"type\"<\/span>: <span class=\"string\">\"text\/html\"<\/span>,\n                <span class=\"string\">\"value\"<\/span>: <span class=\"string\">\"<h1>Welcome to our service!<\/h1>\"<\/span>\n            }]\n        }\n        response = requests.<span class=\"function\">post<\/span>(url, json=payload, headers=headers)\n        <span class=\"keyword\">return<\/span> response.status_code == <span class=\"number\">202<\/span>\n    \n    <span class=\"keyword\">def<\/span> <span class=\"function\">notify_sales_team<\/span>(<span class=\"keyword\">self<\/span>, data, lead_id):\n        <span class=\"string\">\"\"\"Send Slack notification\"\"\"<\/span>\n        payload = {\n            <span class=\"string\">\"text\"<\/span>: <span class=\"string\">f\"\ud83c\udf89 New Lead: {data['first_name']} {data['last_name']}\"<\/span>,\n            <span class=\"string\">\"blocks\"<\/span>: [{\n                <span class=\"string\">\"type\"<\/span>: <span class=\"string\">\"section\"<\/span>,\n                <span class=\"string\">\"text\"<\/span>: {\n                    <span class=\"string\">\"type\"<\/span>: <span class=\"string\">\"mrkdwn\"<\/span>,\n                    <span class=\"string\">\"text\"<\/span>: <span class=\"string\">f\"*New Lead Created*\\n\"<\/span>\n                             <span class=\"string\">f\"Name: {data['first_name']} {data['last_name']}\\n\"<\/span>\n                             <span class=\"string\">f\"Email: {data['email']}\\n\"<\/span>\n                             <span class=\"string\">f\"Company: {data['company']}\\n\"<\/span>\n                             <span class=\"string\">f\"Salesforce ID: {lead_id}\"<\/span>\n                }\n            }]\n        }\n        requests.<span class=\"function\">post<\/span>(<span class=\"keyword\">self<\/span>.slack_webhook, json=payload)\n\n<span class=\"comment\"># Usage<\/span>\nautomation = <span class=\"function\">LeadAutomation<\/span>()\nform_data = {\n    <span class=\"string\">'first_name'<\/span>: <span class=\"string\">'John'<\/span>,\n    <span class=\"string\">'last_name'<\/span>: <span class=\"string\">'Doe'<\/span>,\n    <span class=\"string\">'email'<\/span>: <span class=\"string\">'<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"0d676265634d6e62607d6c6374236e6260\">[email&#160;protected]<\/a>'<\/span>,\n    <span class=\"string\">'company'<\/span>: <span class=\"string\">'Tech Corp'<\/span>\n}\nresult = automation.<span class=\"function\">process_form_submission<\/span>(form_data)<\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 9: Testing & Debugging -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udd0d Testing & Debugging APIs<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>Popular API Testing Tools<\/h3>\n                \n                <div class=\"card-grid\">\n                    <div class=\"card\">\n                        <h4>\ud83d\udcec Postman<\/h4>\n                        <p><strong>Best For:<\/strong> Visual API testing & documentation<\/p>\n                        <ul style=\"margin-top: 10px;\">\n                            <li>Visual request builder<\/li>\n                            <li>Environment variables<\/li>\n                            <li>Collection management<\/li>\n                            <li>Automated testing<\/li>\n                        <\/ul>\n                        <span class=\"badge badge-success\">Free + Pro<\/span>\n                    <\/div>\n                    \n                    <div class=\"card\">\n                        <h4>\u26a1 Insomnia<\/h4>\n                        <p><strong>Best For:<\/strong> REST & GraphQL APIs<\/p>\n                        <ul style=\"margin-top: 10px;\">\n                            <li>Clean interface<\/li>\n                            <li>Code generation<\/li>\n                            <li>GraphQL support<\/li>\n                            <li>Plugin ecosystem<\/li>\n                        <\/ul>\n                        <span class=\"badge badge-info\">Free + Teams<\/span>\n                    <\/div>\n                    \n                    <div class=\"card\">\n                        <h4>\ud83d\udd27 cURL<\/h4>\n                        <p><strong>Best For:<\/strong> Command-line testing<\/p>\n                        <ul style=\"margin-top: 10px;\">\n                            <li>Universal availability<\/li>\n                            <li>Scriptable<\/li>\n                            <li>Lightweight<\/li>\n                            <li>CI\/CD integration<\/li>\n                        <\/ul>\n                        <span class=\"badge badge-primary\">Free & Open Source<\/span>\n                    <\/div>\n                <\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 30px;\">cURL Examples<\/h4>\n                <div class=\"code-block\">\n<span class=\"comment\"># GET request<\/span>\ncurl https:\/\/api.example.com\/users\/123\n\n<span class=\"comment\"># GET with headers<\/span>\ncurl -H <span class=\"string\">\"Authorization: Bearer YOUR_TOKEN\"<\/span> \\\n     -H <span class=\"string\">\"Content-Type: application\/json\"<\/span> \\\n     https:\/\/api.example.com\/data\n\n<span class=\"comment\"># POST request with JSON data<\/span>\ncurl -X POST https:\/\/api.example.com\/users \\\n     -H <span class=\"string\">\"Content-Type: application\/json\"<\/span> \\\n     -d <span class=\"string\">'{\"name\":\"John\",\"email\":\"<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"472d282f2907223f262a372b226924282a\">[email&#160;protected]<\/a>\"}'<\/span>\n\n<span class=\"comment\"># PUT request<\/span>\ncurl -X PUT https:\/\/api.example.com\/users\/123 \\\n     -H <span class=\"string\">\"Content-Type: application\/json\"<\/span> \\\n     -d <span class=\"string\">'{\"name\":\"John Updated\"}'<\/span>\n\n<span class=\"comment\"># DELETE request<\/span>\ncurl -X DELETE https:\/\/api.example.com\/users\/123 \\\n     -H <span class=\"string\">\"Authorization: Bearer YOUR_TOKEN\"<\/span>\n\n<span class=\"comment\"># Save response to file<\/span>\ncurl https:\/\/api.example.com\/data -o response.json\n\n<span class=\"comment\"># Show response headers<\/span>\ncurl -i https:\/\/api.example.com\/data\n\n<span class=\"comment\"># Follow redirects<\/span>\ncurl -L https:\/\/api.example.com\/redirect\n\n<span class=\"comment\"># Upload file<\/span>\ncurl -X POST https:\/\/api.example.com\/upload \\\n     -F <span class=\"string\">\"<a href=\"\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"583e31343d65183c373b2d353d362c76283c3e\">[email&#160;protected]<\/a>\"<\/span> \\\n     -F <span class=\"string\">\"title=My Document\"<\/span><\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Debugging Techniques<\/h3>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Comprehensive API Debugging<\/span>\n<span class=\"keyword\">import<\/span> requests\n<span class=\"keyword\">import<\/span> logging\n<span class=\"keyword\">import<\/span> json\n\n<span class=\"comment\"># Enable detailed logging<\/span>\nlogging.<span class=\"function\">basicConfig<\/span>(level=logging.DEBUG)\n\n<span class=\"comment\"># Enable HTTP request logging<\/span>\n<span class=\"keyword\">import<\/span> http.client\nhttp.client.HTTPConnection.debuglevel = <span class=\"number\">1<\/span>\n\n<span class=\"keyword\">def<\/span> <span class=\"function\">debug_api_call<\/span>(url, method=<span class=\"string\">'GET'<\/span>, **kwargs):\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"\\n{'='*60}\"<\/span>)\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"DEBUG: {method} {url}\"<\/span>)\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"{'='*60}\"<\/span>)\n    \n    <span class=\"comment\"># Print request details<\/span>\n    <span class=\"keyword\">if<\/span> <span class=\"string\">'headers'<\/span> <span class=\"keyword\">in<\/span> kwargs:\n        <span class=\"function\">print<\/span>(<span class=\"string\">\"Headers:\"<\/span>)\n        <span class=\"function\">print<\/span>(json.<span class=\"function\">dumps<\/span>(kwargs[<span class=\"string\">'headers'<\/span>], indent=<span class=\"number\">2<\/span>))\n    \n    <span class=\"keyword\">if<\/span> <span class=\"string\">'json'<\/span> <span class=\"keyword\">in<\/span> kwargs:\n        <span class=\"function\">print<\/span>(<span class=\"string\">\"Request Body:\"<\/span>)\n        <span class=\"function\">print<\/span>(json.<span class=\"function\">dumps<\/span>(kwargs[<span class=\"string\">'json'<\/span>], indent=<span class=\"number\">2<\/span>))\n    \n    <span class=\"comment\"># Make request<\/span>\n    response = requests.<span class=\"function\">request<\/span>(method, url, **kwargs)\n    \n    <span class=\"comment\"># Print response details<\/span>\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"\\nStatus Code: {response.status_code}\"<\/span>)\n    <span class=\"function\">print<\/span>(<span class=\"string\">\"Response Headers:\"<\/span>)\n    <span class=\"keyword\">for<\/span> key, value <span class=\"keyword\">in<\/span> response.headers.<span class=\"function\">items<\/span>():\n        <span class=\"function\">print<\/span>(<span class=\"string\">f\"  {key}: {value}\"<\/span>)\n    \n    <span class=\"function\">print<\/span>(<span class=\"string\">\"\\nResponse Body:\"<\/span>)\n    <span class=\"keyword\">try<\/span>:\n        <span class=\"function\">print<\/span>(json.<span class=\"function\">dumps<\/span>(response.<span class=\"function\">json<\/span>(), indent=<span class=\"number\">2<\/span>))\n    <span class=\"keyword\">except<\/span>:\n        <span class=\"function\">print<\/span>(response.text)\n    \n    <span class=\"keyword\">return<\/span> response\n\n<span class=\"comment\"># Usage<\/span>\nresponse = <span class=\"function\">debug_api_call<\/span>(\n    <span class=\"string\">'https:\/\/api.example.com\/users'<\/span>,\n    method=<span class=\"string\">'POST'<\/span>,\n    headers={<span class=\"string\">'Authorization'<\/span>: <span class=\"string\">'Bearer token123'<\/span>},\n    json={<span class=\"string\">'name'<\/span>: <span class=\"string\">'John Doe'<\/span>}\n)<\/div>\n                \n                <h4 style=\"color: #7B3FF2; margin-top: 25px;\">Common Issues & Solutions<\/h4>\n                \n                <table class=\"comparison-table\">\n                    <thead>\n                        <tr>\n                            <th>Issue<\/th>\n                            <th>Possible Cause<\/th>\n                            <th>Solution<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td>401 Unauthorized<\/td>\n                            <td>Invalid\/missing API key<\/td>\n                            <td>Check API key, verify header format<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>403 Forbidden<\/td>\n                            <td>No permission for resource<\/td>\n                            <td>Verify account permissions\/subscription<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>404 Not Found<\/td>\n                            <td>Wrong endpoint URL<\/td>\n                            <td>Check API documentation, verify URL<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>429 Too Many Requests<\/td>\n                            <td>Rate limit exceeded<\/td>\n                            <td>Implement backoff strategy, slow requests<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>500 Server Error<\/td>\n                            <td>API server issue<\/td>\n                            <td>Retry later, contact API support<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>Timeout<\/td>\n                            <td>Slow API\/network<\/td>\n                            <td>Increase timeout, check network<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>SSL Certificate Error<\/td>\n                            <td>Certificate validation failed<\/td>\n                            <td>Update certificates, check date\/time<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n        <\/div>\n\n        <!-- Section 10: API Security -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\ud83d\udee1\ufe0f API Security Best Practices<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>Security Checklist<\/h3>\n                \n                <div class=\"two-column\">\n                    <div>\n                        <div class=\"best-practice\">\n                            <strong>Authentication & Authorization<\/strong>\n                            <ul>\n                                <li>Always use HTTPS, never HTTP<\/li>\n                                <li>Store API keys in environment variables<\/li>\n                                <li>Use OAuth 2.0 for user data access<\/li>\n                                <li>Implement token expiration<\/li>\n                                <li>Rotate API keys regularly<\/li>\n                            <\/ul>\n                        <\/div>\n                        \n                        <div class=\"best-practice\" style=\"margin-top: 20px;\">\n                            <strong>Data Protection<\/strong>\n                            <ul>\n                                <li>Validate all input data<\/li>\n                                <li>Sanitize user inputs<\/li>\n                                <li>Encrypt sensitive data at rest<\/li>\n                                <li>Use TLS for data in transit<\/li>\n                                <li>Implement data retention policies<\/li>\n                            <\/ul>\n                        <\/div>\n                    <\/div>\n                    \n                    <div>\n                        <div class=\"best-practice\">\n                            <strong>Request Security<\/strong>\n                            <ul>\n                                <li>Implement rate limiting<\/li>\n                                <li>Verify webhook signatures<\/li>\n                                <li>Use IP whitelisting when possible<\/li>\n                                <li>Log all API access attempts<\/li>\n                                <li>Monitor for suspicious activity<\/li>\n                            <\/ul>\n                        <\/div>\n                        \n                        <div class=\"best-practice\" style=\"margin-top: 20px;\">\n                            <strong>Error Handling<\/strong>\n                            <ul>\n                                <li>Don't expose sensitive error details<\/li>\n                                <li>Use generic error messages for users<\/li>\n                                <li>Log detailed errors internally<\/li>\n                                <li>Implement proper exception handling<\/li>\n                                <li>Return appropriate status codes<\/li>\n                            <\/ul>\n                        <\/div>\n                    <\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Secure API Key Management<\/h3>\n                \n                <div class=\"code-block\">\n<span class=\"comment\"># Python: Secure API Key Storage using Environment Variables<\/span>\n<span class=\"keyword\">import<\/span> os\n<span class=\"keyword\">from<\/span> dotenv <span class=\"keyword\">import<\/span> load_dotenv\n\n<span class=\"comment\"># Load environment variables from .env file<\/span>\n<span class=\"function\">load_dotenv<\/span>()\n\n<span class=\"comment\"># Retrieve API keys<\/span>\nOPENAI_API_KEY = os.<span class=\"function\">getenv<\/span>(<span class=\"string\">'OPENAI_API_KEY'<\/span>)\nSTRIPE_API_KEY = os.<span class=\"function\">getenv<\/span>(<span class=\"string\">'STRIPE_API_KEY'<\/span>)\nDATABASE_URL = os.<span class=\"function\">getenv<\/span>(<span class=\"string\">'DATABASE_URL'<\/span>)\n\n<span class=\"comment\"># Validate keys exist<\/span>\n<span class=\"keyword\">if<\/span> <span class=\"keyword\">not<\/span> OPENAI_API_KEY:\n    <span class=\"keyword\">raise<\/span> <span class=\"function\">ValueError<\/span>(<span class=\"string\">\"OPENAI_API_KEY not found in environment\"<\/span>)\n\n<span class=\"comment\"># .env file (NEVER commit to git!):<\/span>\n<span class=\"comment\"># OPENAI_API_KEY=sk-abc123xyz...<\/span>\n<span class=\"comment\"># STRIPE_API_KEY=sk_live_abc123...<\/span>\n<span class=\"comment\"># DATABASE_URL=postgresql:\/\/user:pass@host:5432\/db<\/span>\n\n<span class=\"comment\"># .gitignore file:<\/span>\n<span class=\"comment\"># .env<\/span>\n<span class=\"comment\"># *.key<\/span>\n<span class=\"comment\"># secrets\/<\/span><\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Section 11: Quick Reference -->\n        <div class=\"section\">\n            <h2 class=\"section-title\">\u26a1 Quick Reference<\/h2>\n            \n            <div class=\"subsection\">\n                <h3>HTTP Method Quick Guide<\/h3>\n                <div class=\"status-code-grid\">\n                    <div class=\"status-code status-2xx\">\n                        <strong>GET<\/strong>\n                        <p>Read data<\/p>\n                        <code style=\"font-size: 0.85em;\">GET \/users\/123<\/code>\n                    <\/div>\n                    <div class=\"status-code status-4xx\">\n                        <strong>POST<\/strong>\n                        <p>Create new<\/p>\n                        <code style=\"font-size: 0.85em;\">POST \/users<\/code>\n                    <\/div>\n                    <div class=\"status-code status-3xx\">\n                        <strong>PUT<\/strong>\n                        <p>Full update<\/p>\n                        <code style=\"font-size: 0.85em;\">PUT \/users\/123<\/code>\n                    <\/div>\n                    <div class=\"status-code status-3xx\">\n                        <strong>PATCH<\/strong>\n                        <p>Partial update<\/p>\n                        <code style=\"font-size: 0.85em;\">PATCH \/users\/123<\/code>\n                    <\/div>\n                    <div class=\"status-code status-5xx\">\n                        <strong>DELETE<\/strong>\n                        <p>Remove<\/p>\n                        <code style=\"font-size: 0.85em;\">DELETE \/users\/123<\/code>\n                    <\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Status Code Cheat Sheet<\/h3>\n                <div class=\"two-column\">\n                    <div>\n                        <h4 style=\"color: #28a745;\">\u2713 Success (2xx)<\/h4>\n                        <ul>\n                            <li><strong>200:<\/strong> OK (success)<\/li>\n                            <li><strong>201:<\/strong> Created<\/li>\n                            <li><strong>204:<\/strong> No Content<\/li>\n                        <\/ul>\n                        \n                        <h4 style=\"color: #ffc107; margin-top: 20px;\">\u26a0 Client Errors (4xx)<\/h4>\n                        <ul>\n                            <li><strong>400:<\/strong> Bad Request<\/li>\n                            <li><strong>401:<\/strong> Unauthorized<\/li>\n                            <li><strong>403:<\/strong> Forbidden<\/li>\n                            <li><strong>404:<\/strong> Not Found<\/li>\n                            <li><strong>429:<\/strong> Too Many Requests<\/li>\n                        <\/ul>\n                    <\/div>\n                    <div>\n                        <h4 style=\"color: #17a2b8;\">\u21aa Redirects (3xx)<\/h4>\n                        <ul>\n                            <li><strong>301:<\/strong> Moved Permanently<\/li>\n                            <li><strong>304:<\/strong> Not Modified<\/li>\n                        <\/ul>\n                        \n                        <h4 style=\"color: #dc3545; margin-top: 20px;\">\u2717 Server Errors (5xx)<\/h4>\n                        <ul>\n                            <li><strong>500:<\/strong> Internal Server Error<\/li>\n                            <li><strong>502:<\/strong> Bad Gateway<\/li>\n                            <li><strong>503:<\/strong> Service Unavailable<\/li>\n                        <\/ul>\n                    <\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"subsection\">\n                <h3>Python Requests Library Essentials<\/h3>\n                <div class=\"code-block\">\n<span class=\"comment\"># Import<\/span>\n<span class=\"keyword\">import<\/span> requests\n\n<span class=\"comment\"># Basic requests<\/span>\nrequests.<span class=\"function\">get<\/span>(url)\nrequests.<span class=\"function\">post<\/span>(url, json=data)\nrequests.<span class=\"function\">put<\/span>(url, json=data)\nrequests.<span class=\"function\">delete<\/span>(url)\n\n<span class=\"comment\"># With parameters<\/span>\nrequests.<span class=\"function\">get<\/span>(url, params={<span class=\"string\">'key'<\/span>: <span class=\"string\">'value'<\/span>})\nrequests.<span class=\"function\">post<\/span>(url, json=data, headers=headers, timeout=<span class=\"number\">10<\/span>)\n\n<span class=\"comment\"># Response handling<\/span>\nresponse.status_code    <span class=\"comment\"># HTTP status code<\/span>\nresponse.<span class=\"function\">json<\/span>()         <span class=\"comment\"># Parse JSON response<\/span>\nresponse.text           <span class=\"comment\"># Raw text response<\/span>\nresponse.headers        <span class=\"comment\"># Response headers<\/span>\nresponse.<span class=\"function\">raise_for_status<\/span>()  <span class=\"comment\"># Raise exception for 4xx\/5xx<\/span>\n\n<span class=\"comment\"># Common patterns<\/span>\n<span class=\"keyword\">if<\/span> response.status_code == <span class=\"number\">200<\/span>:\n    data = response.<span class=\"function\">json<\/span>()\n<span class=\"keyword\">else<\/span>:\n    <span class=\"function\">print<\/span>(<span class=\"string\">f\"Error: {response.status_code}\"<\/span>)<\/div>\n            <\/div>\n        <\/div>\n\n        <div class=\"footer\">\n            <p>\u00a9 2024 AiPro Institute | Member Exclusive Resource<\/p>\n            <p style=\"margin-top: 10px; font-size: 0.9em; color: #666;\">\n                Master API Integration \u2022 Build Powerful Automations \u2022 Drive Business Growth\n            <\/p>\n        <\/div>\n    <\/div>\n<script data-cfasync=\"false\" src=\"\/cdn-cgi\/scripts\/5c5dd728\/cloudflare-static\/email-decode.min.js\"><\/script><\/body>\n<\/html>\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>API Integration Guide &#8211; AiPro Institute AiPro Institute \ud83d\udd12 MEMBER EXCLUSIVE RESOURCE \ud83d\udce1 API Integration Guide Master API Integration for Business Applications \ud83c\udfaf API Fundamentals What is an API? API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other. Real-World Analogy: Think of an&hellip;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[87],"tags":[],"class_list":["post-3222","post","type-post","status-publish","format-standard","hentry","category-technical-skills"],"acf":[],"_links":{"self":[{"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/posts\/3222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/comments?post=3222"}],"version-history":[{"count":4,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/posts\/3222\/revisions"}],"predecessor-version":[{"id":3276,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/posts\/3222\/revisions\/3276"}],"wp:attachment":[{"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/media?parent=3222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/categories?post=3222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teen.aiproinstitute.com\/zh\/wp-json\/wp\/v2\/tags?post=3222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}