|
| 1 | +<% content_for :meta_title, t("pages.api.meta_title") %> |
| 2 | +<% content_for :meta_description, t("pages.api.meta_description") %> |
| 3 | + |
| 4 | +<% pre_class = "overflow-x-auto rounded-md bg-gray-900 text-slate-100 p-4 text-xs leading-relaxed dark:bg-slate-900/80" %> |
| 5 | +<% host = ENV.fetch("APP_HOST", "https://getcourt.co") %> |
| 6 | + |
| 7 | +<div class="max-w-5xl mx-auto px-4 py-6"> |
| 8 | + <div class="bg-white dark:bg-slate-800/80 rounded-lg border dark:border-white/10 p-6 shadow-sm mb-6"> |
| 9 | + <h1 class="text-2xl font-semibold mb-2"><%= t("pages.api.title") %></h1> |
| 10 | + <p class="text-gray-600 dark:text-slate-400 mb-6"><%= t("pages.api.subtitle") %></p> |
| 11 | + |
| 12 | + <p class="text-gray-700 dark:text-slate-300 mb-8"><%= t("pages.api.intro") %></p> |
| 13 | + |
| 14 | + <%# ── REST ── %> |
| 15 | + <div class="mb-8"> |
| 16 | + <h2 class="text-lg font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.rest_title") %></h2> |
| 17 | + <p class="text-gray-700 dark:text-slate-300 mb-3"><%= t("pages.api.rest_text") %></p> |
| 18 | + |
| 19 | + <pre class="<%= pre_class %> mb-4">GET <%= host %>/api/v1/games |
| 20 | +GET <%= host %>/api/v1/games/:id</pre> |
| 21 | + |
| 22 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.params_title") %></h3> |
| 23 | + <div class="overflow-x-auto mb-4"> |
| 24 | + <table class="min-w-full text-sm border-collapse"> |
| 25 | + <thead> |
| 26 | + <tr class="bg-gray-50 dark:bg-slate-700/50"> |
| 27 | + <th class="border dark:border-white/10 px-3 py-2 text-left font-medium text-gray-700 dark:text-slate-300 w-40"><%= t("pages.api.param") %></th> |
| 28 | + <th class="border dark:border-white/10 px-3 py-2 text-left font-medium text-gray-700 dark:text-slate-300"><%= t("pages.api.param_meaning") %></th> |
| 29 | + </tr> |
| 30 | + </thead> |
| 31 | + <tbody class="text-gray-700 dark:text-slate-300"> |
| 32 | + <% [ |
| 33 | + [ "city", t("pages.api.param_city") ], |
| 34 | + [ "sport", t("pages.api.param_sport") ], |
| 35 | + [ "skill_level", t("pages.api.param_skill_level") ], |
| 36 | + [ "with_spots", t("pages.api.param_with_spots") ], |
| 37 | + [ "urgent", t("pages.api.param_urgent") ], |
| 38 | + [ "from", t("pages.api.param_from") ], |
| 39 | + [ "to", t("pages.api.param_to") ], |
| 40 | + [ "upcoming", t("pages.api.param_upcoming") ], |
| 41 | + [ "limit", t("pages.api.param_limit") ] |
| 42 | + ].each_with_index do |(name, meaning), index| %> |
| 43 | + <tr class="<%= "bg-gray-50 dark:bg-slate-700/50" if index.odd? %>"> |
| 44 | + <td class="border dark:border-white/10 px-3 py-2 font-mono text-xs"><%= name %></td> |
| 45 | + <td class="border dark:border-white/10 px-3 py-2"><%= meaning %></td> |
| 46 | + </tr> |
| 47 | + <% end %> |
| 48 | + </tbody> |
| 49 | + </table> |
| 50 | + </div> |
| 51 | + <p class="text-sm text-gray-600 dark:text-slate-400 mb-4"><%= t("pages.api.recurring_note") %></p> |
| 52 | + |
| 53 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.example_title") %></h3> |
| 54 | + <pre class="<%= pre_class %> mb-4">curl "<%= host %>/api/v1/games?city=Belgrade&sport=Tennis&with_spots=true&limit=2"</pre> |
| 55 | + |
| 56 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.response_title") %></h3> |
| 57 | + <pre class="<%= pre_class %>">{ |
| 58 | + "games": [ |
| 59 | + { |
| 60 | + "id": 1042, |
| 61 | + "date": "2026-09-12", |
| 62 | + "time": "19:00", |
| 63 | + "duration_minutes": 90, |
| 64 | + "recurring": false, |
| 65 | + "sport": "Tennis", |
| 66 | + "skill_level": "Intermediate", |
| 67 | + "surface": "Hard", |
| 68 | + "environment": "outdoor", |
| 69 | + "kind": "game", |
| 70 | + "with_coach": false, |
| 71 | + "urgent_player_search": true, |
| 72 | + "comment": "Doubles, bring a spare ball", |
| 73 | + "players": { "taken": 3, "total": 4, "spots_left": 1 }, |
| 74 | + "court": { |
| 75 | + "id": 17, |
| 76 | + "name": "Tennis Club Ada", |
| 77 | + "city": "Belgrade", |
| 78 | + "country_code": "RS", |
| 79 | + "latitude": 44.79, |
| 80 | + "longitude": 20.41, |
| 81 | + "indoor": false, |
| 82 | + "outdoor": true, |
| 83 | + "free": false, |
| 84 | + "url": "<%= host %>/courts/17" |
| 85 | + }, |
| 86 | + "url": "<%= host %>/games/1042" |
| 87 | + } |
| 88 | + ] |
| 89 | +}</pre> |
| 90 | + <p class="text-sm text-gray-600 dark:text-slate-400 mt-3"><%= t("pages.api.privacy_note") %></p> |
| 91 | + </div> |
| 92 | + |
| 93 | + <%# ── MCP ── %> |
| 94 | + <div class="mb-8"> |
| 95 | + <h2 class="text-lg font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.mcp_title") %></h2> |
| 96 | + <p class="text-gray-700 dark:text-slate-300 mb-3"><%= t("pages.api.mcp_text") %></p> |
| 97 | + |
| 98 | + <ul class="list-disc pl-5 text-gray-700 dark:text-slate-300 text-sm space-y-1 mb-4"> |
| 99 | + <li><%= t("pages.api.mcp_endpoint_html") %></li> |
| 100 | + <li><%= t("pages.api.mcp_protocol_html") %></li> |
| 101 | + <li><%= t("pages.api.mcp_auth_html") %></li> |
| 102 | + </ul> |
| 103 | + |
| 104 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.tools_title") %></h3> |
| 105 | + <div class="overflow-x-auto mb-4"> |
| 106 | + <table class="min-w-full text-sm border-collapse"> |
| 107 | + <thead> |
| 108 | + <tr class="bg-gray-50 dark:bg-slate-700/50"> |
| 109 | + <th class="border dark:border-white/10 px-3 py-2 text-left font-medium text-gray-700 dark:text-slate-300 w-40"><%= t("pages.api.tool") %></th> |
| 110 | + <th class="border dark:border-white/10 px-3 py-2 text-left font-medium text-gray-700 dark:text-slate-300"><%= t("pages.api.param_meaning") %></th> |
| 111 | + </tr> |
| 112 | + </thead> |
| 113 | + <tbody class="text-gray-700 dark:text-slate-300"> |
| 114 | + <tr> |
| 115 | + <td class="border dark:border-white/10 px-3 py-2 font-mono text-xs">search_games</td> |
| 116 | + <td class="border dark:border-white/10 px-3 py-2"><%= t("pages.api.tool_search") %></td> |
| 117 | + </tr> |
| 118 | + <tr class="bg-gray-50 dark:bg-slate-700/50"> |
| 119 | + <td class="border dark:border-white/10 px-3 py-2 font-mono text-xs">get_game</td> |
| 120 | + <td class="border dark:border-white/10 px-3 py-2"><%= t("pages.api.tool_get") %></td> |
| 121 | + </tr> |
| 122 | + </tbody> |
| 123 | + </table> |
| 124 | + </div> |
| 125 | + |
| 126 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.client_title") %></h3> |
| 127 | + <p class="text-gray-700 dark:text-slate-300 mb-3"><%= t("pages.api.client_text") %></p> |
| 128 | + <pre class="<%= pre_class %> mb-4">{ |
| 129 | + "mcpServers": { |
| 130 | + "getcourt": { |
| 131 | + "type": "http", |
| 132 | + "url": "<%= host %>/mcp", |
| 133 | + "headers": { "Authorization": "Bearer YOUR_TOKEN" } |
| 134 | + } |
| 135 | + } |
| 136 | +}</pre> |
| 137 | + |
| 138 | + <h3 class="text-sm font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.raw_title") %></h3> |
| 139 | + <pre class="<%= pre_class %>">curl -X POST <%= host %>/mcp \ |
| 140 | + -H "Content-Type: application/json" \ |
| 141 | + -H "Authorization: Bearer YOUR_TOKEN" \ |
| 142 | + -d '{"jsonrpc":"2.0","id":1,"method":"tools/call", |
| 143 | + "params":{"name":"search_games","arguments":{"city":"Belgrade","with_spots":true}}}'</pre> |
| 144 | + </div> |
| 145 | + |
| 146 | + <%# ── Limits ── %> |
| 147 | + <div class="mb-8"> |
| 148 | + <h2 class="text-lg font-medium text-gray-900 dark:text-slate-100 mb-2"><%= t("pages.api.limits_title") %></h2> |
| 149 | + <ul class="list-disc pl-5 text-gray-700 dark:text-slate-300 text-sm space-y-1"> |
| 150 | + <li><%= t("pages.api.limits_rest") %></li> |
| 151 | + <li><%= t("pages.api.limits_mcp") %></li> |
| 152 | + <li><%= t("pages.api.limits_read_only") %></li> |
| 153 | + </ul> |
| 154 | + </div> |
| 155 | + |
| 156 | + <div class="flex flex-wrap gap-3"> |
| 157 | + <%= link_to t("pages.api.get_token"), contacts_path, class: "inline-flex items-center rounded-md bg-indigo-600 px-4 py-2 text-white hover:bg-indigo-500" %> |
| 158 | + <%= link_to t("pages.api.source_code"), "https://github.com/denis1011101/getcourt/blob/main/docs/api-and-mcp.md", target: "_blank", rel: "noopener", |
| 159 | + class: "inline-flex items-center rounded-md border dark:border-white/10 px-4 py-2 text-gray-700 dark:text-slate-300 hover:bg-gray-50 dark:hover:bg-white/5" %> |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + |
| 163 | + <%= render "shared/pages_nav" %> |
| 164 | +</div> |
0 commit comments