From e977bce6d89a5786e687b1e32d85d3e09c19183d Mon Sep 17 00:00:00 2001 From: Laura Coursen Date: Fri, 10 May 2024 09:20:12 -0500 Subject: [PATCH] Combine product name variables for REST and GraphQL API base URLs (#50521) --- ...reating-custom-deployment-protection-rules.md | 2 +- .../actions/learn-github-actions/variables.md | 4 ++-- .../automatic-token-authentication.md | 2 +- ...sing-the-audit-log-api-for-your-enterprise.md | 16 ++++++++-------- ...uthenticating-as-a-github-app-installation.md | 2 +- .../authenticating-as-a-github-app.md | 2 +- ...ting-a-json-web-token-jwt-for-a-github-app.md | 12 ++++++------ .../building-a-cli-with-a-github-app.md | 4 ++-- ...login-with-github-button-with-a-github-app.md | 4 ++-- ...ticating-to-the-rest-api-with-an-oauth-app.md | 8 ++++---- .../authorizing-oauth-apps.md | 4 ++-- .../building-oauth-apps/scopes-for-oauth-apps.md | 2 +- ...t-environment-variables-for-your-codespace.md | 4 ++-- .../graphql/guides/forming-calls-with-graphql.md | 4 ++-- .../graphql/guides/introduction-to-graphql.md | 4 ++-- .../guides/migrating-from-rest-to-graphql.md | 14 +++++++------- content/graphql/guides/using-global-node-ids.md | 2 +- content/graphql/guides/using-the-explorer.md | 2 +- content/rest/activity/events.md | 4 ++-- content/rest/activity/notifications.md | 4 ++-- .../authenticating-to-the-rest-api.md | 8 ++++---- content/rest/enterprise-admin/index.md | 2 +- content/rest/enterprise-admin/scim.md | 4 ++-- ...scripting-with-the-rest-api-and-javascript.md | 12 ++++++------ content/rest/quickstart.md | 14 +++++++------- content/rest/scim/scim.md | 2 +- content/rest/search/search.md | 2 +- .../best-practices-for-using-the-rest-api.md | 4 ++-- .../getting-started-with-the-rest-api.md | 12 ++++++------ .../rate-limits-for-the-rest-api.md | 2 +- .../timezones-and-the-rest-api.md | 2 +- ...rs-and-jsonp-to-make-cross-origin-requests.md | 10 +++++----- .../using-pagination-in-the-rest-api.md | 4 ++-- ...failed-deliveries-for-a-github-app-webhook.md | 4 ++-- ...failed-deliveries-for-a-repository-webhook.md | 2 +- ...led-deliveries-for-an-organization-webhook.md | 2 +- content/webhooks/webhook-events-and-payloads.md | 2 +- .../apps/generate-installation-access-token.md | 2 +- .../apps/user-access-token-example-request.md | 2 +- data/variables/product.yml | 14 +++----------- 40 files changed, 99 insertions(+), 107 deletions(-) diff --git a/content/actions/deployment/protecting-deployments/creating-custom-deployment-protection-rules.md b/content/actions/deployment/protecting-deployments/creating-custom-deployment-protection-rules.md index ab29509c23..25f36745c9 100644 --- a/content/actions/deployment/protecting-deployments/creating-custom-deployment-protection-rules.md +++ b/content/actions/deployment/protecting-deployments/creating-custom-deployment-protection-rules.md @@ -57,7 +57,7 @@ Once a workflow reaches a job that references an environment that has the custom ```shell curl --request POST \ - --url "{% data variables.product.api_url_code %}/app/installations/INSTALLATION_ID/ACCESS_TOKENS" \ + --url "{% data variables.product.rest_url %}/app/installations/INSTALLATION_ID/ACCESS_TOKENS" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer {jwt}" \ --header "Content-Type: application/json" \ diff --git a/content/actions/learn-github-actions/variables.md b/content/actions/learn-github-actions/variables.md index cf692e1815..42cc689d13 100644 --- a/content/actions/learn-github-actions/variables.md +++ b/content/actions/learn-github-actions/variables.md @@ -278,12 +278,12 @@ We strongly recommend that actions use variables to access the filesystem rather {%- ifversion actions-oidc-custom-claims %} | `GITHUB_ACTOR_ID` | {% data reusables.actions.actor_id-description %} | {%- endif %} -| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.api_url_code %}`. +| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.rest_url %}`. | `GITHUB_BASE_REF` | The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `main`. | | `GITHUB_ENV` | The path on the runner to the file that sets variables from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a`. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)." | | `GITHUB_EVENT_NAME` | The name of the event that triggered the workflow. For example, `workflow_dispatch`. | | `GITHUB_EVENT_PATH` | The path to the file on the runner that contains the full event webhook payload. For example, `/github/workflow/event.json`. | -| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url_code %}`. +| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url %}`. | `GITHUB_HEAD_REF` | The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `feature-branch-1`. | | `GITHUB_JOB` | The [job_id](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_id) of the current job. For example, `greeting_job`. | | `GITHUB_OUTPUT` | The path on the runner to the file that sets the current step's outputs from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_output_a50ef383-b063-46d9-9157-57953fc9f3f0`. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)." | diff --git a/content/actions/security-guides/automatic-token-authentication.md b/content/actions/security-guides/automatic-token-authentication.md index 4eb1bf19bd..0780248ab4 100644 --- a/content/actions/security-guides/automatic-token-authentication.md +++ b/content/actions/security-guides/automatic-token-authentication.md @@ -61,7 +61,7 @@ jobs: - name: Create issue using REST API run: | curl --request POST \ - --url {% data variables.product.api_url_code %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \ + --url {% data variables.product.rest_url %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \ --header 'authorization: Bearer ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}' \ --header 'content-type: application/json' \ --data '{ diff --git a/content/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise.md b/content/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise.md index 9215729e8c..b79b61f004 100644 --- a/content/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise.md +++ b/content/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise.md @@ -49,7 +49,7 @@ The query below searches for audit log events created on Jan 1st, 2022 in the `a ```shell curl -H "Authorization: Bearer TOKEN" \ --request GET \ -"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&page=1&per_page=100" +"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&page=1&per_page=100" ``` {% else %} @@ -59,15 +59,15 @@ The query below searches for audit log events created on Jan 1st, 2022 in the `a ```shell curl --include -H "Authorization: Bearer TOKEN" \ --request GET \ -"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&per_page=100" +"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&per_page=100" ``` If there are more than 100 results, the `link` header will include URLs to fetch the next, first, and previous pages of results. ```text -link: <{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42NjQzODMzNTk5MjdlKzEyfDloQzBxdURzaFdVbVlLWjkxRU9mNXc%3D&before=>; rel="next", -<{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=>; rel="first", -<{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=MS42Njc4NDA2MjM4MzNlKzEyfExqeG5sUElvNEZMbG1XZHA5akdKTVE%3D>; rel="prev" +link: <{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42NjQzODMzNTk5MjdlKzEyfDloQzBxdURzaFdVbVlLWjkxRU9mNXc%3D&before=>; rel="next", +<{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=>; rel="first", +<{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=MS42Njc4NDA2MjM4MzNlKzEyfExqeG5sUElvNEZMbG1XZHA5akdKTVE%3D>; rel="prev" ``` Copy the corresponding pagination link into your next request. For example: @@ -75,7 +75,7 @@ Copy the corresponding pagination link into your next request. For example: ```shell curl -I -H "Authorization: Bearer TOKEN" \ --request GET \ -"{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42Njc4NDA2MjM5NDFlKzEyfHRYa3AwSkxUd2xyRjA5bWxfOS1RbFE%3D&before=" +"{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42Njc4NDA2MjM5NDFlKzEyfHRYa3AwSkxUd2xyRjA5bWxfOS1RbFE%3D&before=" ``` {% endif %} @@ -89,7 +89,7 @@ The query below searches for audit log events for pull requests, where the event ```shell curl -H "Authorization: Bearer TOKEN" \ --request GET \ -"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=action:pull_request+created:>=2022-01-01+actor:octocat" +"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=action:pull_request+created:>=2022-01-01+actor:octocat" ``` ## Example 3: Events for Git activity in an enterprise, for a specific date and actor @@ -101,5 +101,5 @@ The query below searches for audit log events for Git activity, where the event ```shell curl -H "Authorization: Bearer TOKEN" \ --request GET \ -"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:>=2024-01-01+actor:octocat&include=git" +"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:>=2024-01-01+actor:octocat&include=git" ``` diff --git a/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md b/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md index f147073b99..e95f596da0 100644 --- a/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md +++ b/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md @@ -46,7 +46,7 @@ In the following example, replace `INSTALLATION_ACCESS_TOKEN` with an installati ```shell curl --request GET \ ---url "{% data variables.product.api_url_pre %}/meta" \ +--url "{% data variables.product.rest_url %}/meta" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer INSTALLATION_ACCESS_TOKEN" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" diff --git a/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app.md b/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app.md index 4d2150b397..c690b83dc1 100644 --- a/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app.md +++ b/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app.md @@ -23,7 +23,7 @@ If a REST API endpoint requires you to authenticate as an app, the documentation ```shell curl --request GET \ - --url "{% data variables.product.api_url_pre %}/app/installations" \ + --url "{% data variables.product.rest_url %}/app/installations" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer YOUR_JWT" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" diff --git a/content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md b/content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md index 6d30192766..bae0b79ead 100644 --- a/content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md +++ b/content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md @@ -27,7 +27,7 @@ To use a JWT, pass it in the `Authorization` header of an API request. For examp ```shell curl --request GET \ ---url "{% data variables.product.api_url_pre %}/app" \ +--url "{% data variables.product.rest_url %}/app" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer YOUR_JWT" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" @@ -128,7 +128,7 @@ payload = { # {% data variables.product.prodname_github_app %}'s client ID 'iss': client_id{% else %} # {% data variables.product.prodname_github_app %}'s app ID - 'iss': app_id{% endif %} + 'iss': app_id{% endif %} } # Create JWT @@ -156,7 +156,7 @@ set -o pipefail client_id=$1 # Client ID as first argument {% else %} app_id=$1 # App ID as first argument -{% endif %} +{% endif %} pem=$( cat $2 ) # file path of the private key as second argument now=$(date +%s) @@ -175,7 +175,7 @@ header=$( echo -n "${header_json}" | b64enc ) payload_json='{ "iat":'"${iat}"', "exp":'"${exp}"', - {% ifversion client-id-for-app %}"iss":'"${client_id}"'{% else %}"iss":'"${client_id}"'{% endif %} + {% ifversion client-id-for-app %}"iss":'"${client_id}"'{% else %}"iss":'"${client_id}"'{% endif %} }' # Payload encode payload=$( echo -n "${payload_json}" | b64enc ) @@ -203,7 +203,7 @@ In the following example, replace `YOUR_PATH_TO_PEM` with the file path where yo $client_id = YOUR_CLIENT_ID {% else %} $app_id = YOUR_APP_ID -{% endif %} +{% endif %} $private_key_path = "YOUR_PATH_TO_PEM" $header = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @{ @@ -214,7 +214,7 @@ $header = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Conve $payload = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @{ iat = [System.DateTimeOffset]::UtcNow.AddSeconds(-10).ToUnixTimeSeconds() exp = [System.DateTimeOffset]::UtcNow.AddMinutes(10).ToUnixTimeSeconds() - {% ifversion client-id-for-app %} iss = $client_id{% else %} iss = $app_id{% endif %} + {% ifversion client-id-for-app %} iss = $client_id{% else %} iss = $app_id{% endif %} }))).TrimEnd('=').Replace('+', '-').Replace('/', '_'); $rsa = [System.Security.Cryptography.RSA]::Create() diff --git a/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app.md b/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app.md index 5e7bab1c0d..a28afabdcb 100644 --- a/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app.md +++ b/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app.md @@ -490,7 +490,7 @@ Now that your app can generate a user access token, you can make API requests on ```ruby copy def whoami - uri = URI("{% data variables.product.api_url_code %}/user") + uri = URI("{% data variables.product.rest_url %}/user") begin token = File.read("./.token").strip @@ -675,7 +675,7 @@ This is the full code example that was outlined in the previous section. Replace end def whoami - uri = URI("{% data variables.product.api_url_code %}/user") + uri = URI("{% data variables.product.rest_url %}/user") begin token = File.read("./.token").strip diff --git a/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-login-with-github-button-with-a-github-app.md b/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-login-with-github-button-with-a-github-app.md index a166087380..2f8139d2d2 100644 --- a/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-login-with-github-button-with-a-github-app.md +++ b/content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-login-with-github-button-with-a-github-app.md @@ -249,7 +249,7 @@ These steps lead you through writing code to generate a user access token. To sk ```ruby copy def user_info(token) - uri = URI("{% data variables.product.api_url_code %}/user") + uri = URI("{% data variables.product.rest_url %}/user") result = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| body = {"access_token" => token}.to_json @@ -332,7 +332,7 @@ def exchange_code(code) end def user_info(token) - uri = URI("{% data variables.product.api_url_code %}/user") + uri = URI("{% data variables.product.rest_url %}/user") result = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| body = {"access_token" => token}.to_json diff --git a/content/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app.md b/content/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app.md index aba2efeec9..f43fd8d998 100644 --- a/content/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app.md +++ b/content/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app.md @@ -182,13 +182,13 @@ the logged in user: ``` ruby # fetch user information -auth_result = JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user', +auth_result = JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user', {:params => {:access_token => access_token}})) # if the user authorized it, fetch private emails if has_user_email_scope auth_result['private_emails'] = - JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user/emails', + JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user/emails', {:params => {:access_token => access_token}})) end @@ -271,7 +271,7 @@ get '/' do scopes = [] begin - auth_result = RestClient.get('{% data variables.product.api_url_code %}/user', + auth_result = RestClient.get('{% data variables.product.rest_url %}/user', {:params => {:access_token => access_token}, :accept => :json}) rescue => e @@ -292,7 +292,7 @@ get '/' do if scopes.include? 'user:email' auth_result['private_emails'] = - JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user/emails', + JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user/emails', {:params => {:access_token => access_token}, :accept => :json})) end diff --git a/content/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps.md b/content/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps.md index 1f919a2d57..44cc1f35b3 100644 --- a/content/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps.md +++ b/content/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps.md @@ -116,12 +116,12 @@ Accept: application/xml The access token allows you to make requests to the API on a behalf of a user. Authorization: Bearer OAUTH-TOKEN - GET {% data variables.product.api_url_code %}/user + GET {% data variables.product.rest_url %}/user For example, in curl you can set the Authorization header like this: ```shell -curl -H "Authorization: Bearer OAUTH-TOKEN" {% data variables.product.api_url_pre %}/user +curl -H "Authorization: Bearer OAUTH-TOKEN" {% data variables.product.rest_url %}/user ``` ## Device flow diff --git a/content/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps.md b/content/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps.md index 97ad1ad6d2..0cb09caf4f 100644 --- a/content/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps.md +++ b/content/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps.md @@ -34,7 +34,7 @@ If your {% data variables.product.prodname_oauth_app %} doesn't have access to a Check headers to see what OAuth scopes you have, and what the API action accepts: ```shell -$ curl -H "Authorization: Bearer OAUTH-TOKEN" {% data variables.product.api_url_pre %}/users/codertocat -I +$ curl -H "Authorization: Bearer OAUTH-TOKEN" {% data variables.product.rest_url %}/users/codertocat -I HTTP/2 200 X-OAuth-Scopes: repo, user X-Accepted-OAuth-Scopes: user diff --git a/content/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace.md b/content/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace.md index 082a4a17b7..13dba8f1ab 100644 --- a/content/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace.md +++ b/content/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace.md @@ -33,8 +33,8 @@ redirect_from: | `GIT_COMMITTER_EMAIL` | The email for the "author" field of future `git` commits. | | `GIT_COMMITTER_NAME` | The name for the "committer" field of future `git` commits. | | `GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN`| Returns the domain of the {% data variables.product.prodname_github_codespaces %} forwarded port. For example, `app.github.dev`. | -| `GITHUB_API_URL` | Returns the API URL. For example, `{% data variables.product.api_url_code %}`. | -| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example, `{% data variables.product.graphql_url_code %}`. | +| `GITHUB_API_URL` | Returns the API URL. For example, `{% data variables.product.rest_url %}`. | +| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example, `{% data variables.product.graphql_url %}`. | | `GITHUB_REPOSITORY` | The owner and repository name. For example, `octocat/Hello-World`. | | `GITHUB_SERVER_URL`| Returns the URL of the {% data variables.product.product_name %} server. For example, `https://{% data variables.product.product_url %}`. | | `GITHUB_TOKEN` | A signed auth token representing the user in the codespace. You can use this to make authenticated calls to the GitHub API. For more information, see "[AUTOTITLE](/codespaces/reference/security-in-github-codespaces#authentication)." | diff --git a/content/graphql/guides/forming-calls-with-graphql.md b/content/graphql/guides/forming-calls-with-graphql.md index d0028cc488..90d2eed0fa 100644 --- a/content/graphql/guides/forming-calls-with-graphql.md +++ b/content/graphql/guides/forming-calls-with-graphql.md @@ -44,7 +44,7 @@ To authenticate with an OAuth token from an {% data variables.product.prodname_o The REST API has numerous endpoints; the GraphQL API has a single endpoint: -
{% data variables.product.graphql_url_pre %}
+
{% data variables.product.graphql_url %}
The endpoint remains constant no matter what operation you perform. @@ -61,7 +61,7 @@ curl -H "Authorization: bearer TOKEN" -X POST -d " \ { \ \"query\": \"query { viewer { login }}\" \ } \ -" {% data variables.product.graphql_url_code %} +" {% data variables.product.graphql_url %} ``` {% tip %} diff --git a/content/graphql/guides/introduction-to-graphql.md b/content/graphql/guides/introduction-to-graphql.md index 8ae94bf4d3..c6e54242e4 100644 --- a/content/graphql/guides/introduction-to-graphql.md +++ b/content/graphql/guides/introduction-to-graphql.md @@ -115,7 +115,7 @@ GraphQL is [introspective](https://graphql.org/learn/introspection/). This means - You can also run an _introspection query_ of the schema via a `GET` request: ```shell - curl -H "Authorization: bearer TOKEN" {% data variables.product.graphql_url_pre %} + curl -H "Authorization: bearer TOKEN" {% data variables.product.graphql_url %} ``` {% note %} @@ -130,7 +130,7 @@ GraphQL is [introspective](https://graphql.org/learn/introspection/). This means ```shell $ curl -H "Authorization: bearer TOKEN" -H "Accept: application/vnd.github.v4.idl" \ - {% data variables.product.graphql_url_pre %} + {% data variables.product.graphql_url %} ``` {% note %} diff --git a/content/graphql/guides/migrating-from-rest-to-graphql.md b/content/graphql/guides/migrating-from-rest-to-graphql.md index 590e529d81..be91a9e6a9 100644 --- a/content/graphql/guides/migrating-from-rest-to-graphql.md +++ b/content/graphql/guides/migrating-from-rest-to-graphql.md @@ -39,7 +39,7 @@ Here are examples of each. A single REST API call retrieves a list of your organization's members: ```shell -curl -v {% data variables.product.api_url_pre %}/orgs/:org/members +curl -v {% data variables.product.rest_url %}/orgs/:org/members ``` The REST payload contains excessive data if your goal is to retrieve only member names and links to avatars. However, a GraphQL query returns only what you specify: @@ -62,13 +62,13 @@ query { Consider another example: retrieving a list of pull requests and checking if each one is mergeable. A call to the REST API retrieves a list of pull requests and their [summary representations](/rest#summary-representations): ```shell -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/pulls +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/pulls ``` Determining if a pull request is mergeable requires retrieving each pull request individually for its [detailed representation](/rest#detailed-representations) (a large payload) and checking whether its `mergeable` attribute is true or false: ```shell -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/pulls/:number +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/pulls/:number ``` With GraphQL, you could retrieve only the `number` and `mergeable` attributes for each pull request: @@ -93,10 +93,10 @@ query { Querying with nested fields lets you replace multiple REST calls with fewer GraphQL queries. For example, retrieving a pull request along with its commits, non-review comments, and reviews using the **REST API** requires four separate calls: ```shell -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/pulls/:number -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/pulls/:number/commits -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/issues/:number/comments -curl -v {% data variables.product.api_url_pre %}/repos/:owner/:repo/pulls/:number/reviews +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/pulls/:number +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/pulls/:number/commits +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/issues/:number/comments +curl -v {% data variables.product.rest_url %}/repos/:owner/:repo/pulls/:number/reviews ``` Using the **GraphQL API**, you can retrieve the data with a single query using nested fields: diff --git a/content/graphql/guides/using-global-node-ids.md b/content/graphql/guides/using-global-node-ids.md index 571e77b7a9..e4f96ff46d 100644 --- a/content/graphql/guides/using-global-node-ids.md +++ b/content/graphql/guides/using-global-node-ids.md @@ -34,7 +34,7 @@ Let's walk through an example. If you [request the authenticated user](/rest/users/users#get-the-authenticated-user): ```shell -curl -i --header "Authorization: Bearer YOUR-TOKEN" {% data variables.product.api_url_pre %}/user +curl -i --header "Authorization: Bearer YOUR-TOKEN" {% data variables.product.rest_url %}/user ``` you'll get a response that includes the `node_id` of the authenticated user: diff --git a/content/graphql/guides/using-the-explorer.md b/content/graphql/guides/using-the-explorer.md index d9ff4cbc31..5e75b84ee4 100644 --- a/content/graphql/guides/using-the-explorer.md +++ b/content/graphql/guides/using-the-explorer.md @@ -87,7 +87,7 @@ There are many open source GraphQL client IDEs. For example, you can use Altair 1. In the "Header key" field, enter `Authorization`. 1. In the "Header value" field, enter `Bearer TOKEN`, replacing `TOKEN` with your token from the first step. 1. Click **Save** in the bottom right corner of the window to save your authorization header. -1. In the "GraphQL Endpoint" field, enter `{% data variables.product.graphql_url_pre %}`. +1. In the "GraphQL Endpoint" field, enter `{% data variables.product.graphql_url %}`. 1. To load the {% data variables.product.company_short %} GraphQL schema, download the [public schema](/graphql/overview/public-schema). 1. In Altair, click on **Docs** on the top right, then the three dots and **Load Schema...** 1. Select the file public schema that you downloaded in an earlier step. diff --git a/content/rest/activity/events.md b/content/rest/activity/events.md index 1a06b8bdbd..142df9f49d 100644 --- a/content/rest/activity/events.md +++ b/content/rest/activity/events.md @@ -23,13 +23,13 @@ You can use the REST API to return different types of events triggered by activi Events are optimized for polling with the "ETag" header. If no new events have been triggered, you will see a "304 Not Modified" response, and your current rate limit will be untouched. There is also an "X-Poll-Interval" header that specifies how often (in seconds) you are allowed to poll. In times of high server load, the time may increase. Please obey the header. ``` shell -$ curl -I {% data variables.product.api_url_pre %}/users/tater/events +$ curl -I {% data variables.product.rest_url %}/users/tater/events > HTTP/2 200 > X-Poll-Interval: 60 > ETag: "a18c3bded88eb5dbb5c849a489412bf3" # The quotes around the ETag value are important -$ curl -I {% data variables.product.api_url_pre %}/users/tater/events \ +$ curl -I {% data variables.product.rest_url %}/users/tater/events \ $ -H 'If-None-Match: "a18c3bded88eb5dbb5c849a489412bf3"' > HTTP/2 304 > X-Poll-Interval: 60 diff --git a/content/rest/activity/notifications.md b/content/rest/activity/notifications.md index 8ccb89b518..8a9195d9ed 100644 --- a/content/rest/activity/notifications.md +++ b/content/rest/activity/notifications.md @@ -28,13 +28,13 @@ Notifications are optimized for polling with the `Last-Modified` header. If the ``` shell # Add authentication to your requests -$ curl -I {% data variables.product.api_url_pre %}/notifications +$ curl -I {% data variables.product.rest_url %}/notifications HTTP/2 200 Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT X-Poll-Interval: 60 # Pass the Last-Modified header exactly -$ curl -I {% data variables.product.api_url_pre %}/notifications +$ curl -I {% data variables.product.rest_url %}/notifications $ -H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT" > HTTP/2 304 > X-Poll-Interval: 60 diff --git a/content/rest/authentication/authenticating-to-the-rest-api.md b/content/rest/authentication/authenticating-to-the-rest-api.md index e915afef23..87e0065644 100644 --- a/content/rest/authentication/authenticating-to-the-rest-api.md +++ b/content/rest/authentication/authenticating-to-the-rest-api.md @@ -24,7 +24,7 @@ After creating a token, you can authenticate your request by sending the token i ```shell curl --request GET \ ---url "{% data variables.product.api_url_code %}/octocat" \ +--url "{% data variables.product.rest_url %}/octocat" \ --header "Authorization: Bearer YOUR-TOKEN" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" ``` @@ -77,7 +77,7 @@ For example: ```shell curl --request POST \ ---url "{% data variables.product.api_url_code %}/applications/YOUR_CLIENT_ID/token" \ +--url "{% data variables.product.rest_url %}/applications/YOUR_CLIENT_ID/token" \ --user "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \ --header "Accept: application/vnd.github+json" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" \ @@ -142,7 +142,7 @@ jobs: GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} run: | curl --request GET \ - --url "{% data variables.product.api_url_code %}/PATH" \ + --url "{% data variables.product.rest_url %}/PATH" \ --header "Authorization: Bearer $GH_TOKEN" ``` @@ -158,7 +158,7 @@ For an example of how to authenticate in a {% data variables.product.prodname_ac ```shell curl --request GET \ ---url "{% data variables.product.api_url_code %}/user" \ +--url "{% data variables.product.rest_url %}/user" \ --user USERNAME:PASSWORD \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" ``` diff --git a/content/rest/enterprise-admin/index.md b/content/rest/enterprise-admin/index.md index 1a56159b5a..d608d2e1ee 100644 --- a/content/rest/enterprise-admin/index.md +++ b/content/rest/enterprise-admin/index.md @@ -50,7 +50,7 @@ autogenerated: rest These endpoints{% ifversion ghes %}—except [Management Console](#management-console) endpoints—{% endif %} are prefixed with the following URL: ```shell -{% data variables.product.api_url_pre %} +{% data variables.product.rest_url %} ``` {% ifversion fpt or ghec %} diff --git a/content/rest/enterprise-admin/scim.md b/content/rest/enterprise-admin/scim.md index 4a3524720d..d03ccacb80 100644 --- a/content/rest/enterprise-admin/scim.md +++ b/content/rest/enterprise-admin/scim.md @@ -34,7 +34,7 @@ autogenerated: rest To manage your enterprise's users and groups using SCIM, use the following base URL to communicate with the endpoints in this category. ```http -{% data variables.product.api_url_code %}/scim/v2/enterprises/{enterprise}/ +{% data variables.product.rest_url %}/scim/v2/enterprises/{enterprise}/ ``` ### Authentication @@ -109,7 +109,7 @@ These endpoints are based on SCIM 2.0. For more information, refer to your IdP's An IdP can use the following root URL to communicate with the endpoints in this category for a {% data variables.product.product_name %} instance. ```http -{% data variables.product.api_url_code %}/scim/v2/ +{% data variables.product.rest_url %}/scim/v2/ ``` Endpoints in this category are case-sensitive. For example, the first letter in the `Users` endpoint must be capitalized. diff --git a/content/rest/guides/scripting-with-the-rest-api-and-javascript.md b/content/rest/guides/scripting-with-the-rest-api-and-javascript.md index a9db583278..a34696828a 100644 --- a/content/rest/guides/scripting-with-the-rest-api-and-javascript.md +++ b/content/rest/guides/scripting-with-the-rest-api-and-javascript.md @@ -46,7 +46,7 @@ First, import `Octokit` from `octokit`. Then, pass your {% data variables.produc import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: 'YOUR-TOKEN', }); ``` @@ -64,7 +64,7 @@ const app = new App({ appId: APP_ID, privateKey: PRIVATE_KEY,{% ifversion ghes %} Octokit: Octokit.defaults({ - baseUrl: "{% data variables.product.api_url_code %}", + baseUrl: "{% data variables.product.rest_url %}", }),{% endif %} }); @@ -95,20 +95,20 @@ The script that the workflow runs uses `process.env.TOKEN` to authenticate: import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: process.env.TOKEN, }); ``` ### Instantiating without authentication -You can use the REST API without authentication, although you will have a lower rate limit and will not be able to use some endpoints. To create an instance of `Octokit` without authenticating, do not pass the `auth` argument.{% ifversion ghes %} Set the base URL to `{% data variables.product.api_url_code %}`. Replace `[hostname]` with the name of {% data variables.location.product_location %}.{% endif %} +You can use the REST API without authentication, although you will have a lower rate limit and will not be able to use some endpoints. To create an instance of `Octokit` without authenticating, do not pass the `auth` argument.{% ifversion ghes %} Set the base URL to `{% data variables.product.rest_url %}`. Replace `[hostname]` with the name of {% data variables.location.product_location %}.{% endif %} ```javascript copy import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}", + baseUrl: "{% data variables.product.rest_url %}", {% endif %}}); ``` @@ -364,7 +364,7 @@ The `getChangedFiles` function gets all of the files changed for a pull request. import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: 'YOUR-TOKEN', }); diff --git a/content/rest/quickstart.md b/content/rest/quickstart.md index 4b40656b57..8c050e124e 100644 --- a/content/rest/quickstart.md +++ b/content/rest/quickstart.md @@ -56,7 +56,7 @@ jobs: - env: GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} run: | - gh api {% data variables.product.api_url_code %}{% data variables.rest.example_request_url %} + gh api {% data variables.product.rest_url %}{% data variables.rest.example_request_url %} ``` ### Authenticating with a {% data variables.product.prodname_github_app %} @@ -89,7 +89,7 @@ If you are authenticating with a {% data variables.product.prodname_github_app % env: GH_TOKEN: {% raw %}${{ steps.generate-token.outputs.token }}{% endraw %} run: | - gh api {% data variables.product.api_url_code %}{% data variables.rest.example_request_url %} + gh api {% data variables.product.rest_url %}{% data variables.rest.example_request_url %} ``` {% endcli %} @@ -122,7 +122,7 @@ You can use Octokit.js to interact with the {% data variables.product.prodname_d ```javascript copy const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: 'YOUR-TOKEN' }); ``` @@ -187,7 +187,7 @@ The following is an example JavaScript script with the file path `.github/action import { Octokit } from "octokit" const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: process.env.TOKEN }); @@ -287,7 +287,7 @@ If you are authenticating with a {% data variables.product.prodname_github_app % ```shell copy curl --request GET \ - --url "{% data variables.product.api_url_code %}{% data variables.rest.example_request_url %}" \ + --url "{% data variables.product.rest_url %}{% data variables.rest.example_request_url %}" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer YOUR-TOKEN" ``` @@ -321,7 +321,7 @@ jobs: GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} run: | curl --request GET \ - --url "{% data variables.product.api_url_code %}{% data variables.rest.example_request_url %}" \ + --url "{% data variables.product.rest_url %}{% data variables.rest.example_request_url %}" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer $GH_TOKEN" ``` @@ -358,7 +358,7 @@ If you are authenticating with a {% data variables.product.prodname_github_app % GH_TOKEN: {% raw %}${{ steps.generate-token.outputs.token }}{% endraw %} run: | curl --request GET \ - --url "{% data variables.product.api_url_code %}{% data variables.rest.example_request_url %}" \ + --url "{% data variables.product.rest_url %}{% data variables.rest.example_request_url %}" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer $GH_TOKEN" diff --git a/content/rest/scim/scim.md b/content/rest/scim/scim.md index fe2ece1975..cb73d1a31a 100644 --- a/content/rest/scim/scim.md +++ b/content/rest/scim/scim.md @@ -20,7 +20,7 @@ autogenerated: rest ### SCIM Provisioning for Organizations -These endpoints are used by SCIM-enabled Identity Providers (IdPs) to automate provisioning of {% data variables.product.product_name %} organization membership and are based on version 2.0 of the [SCIM standard](http://www.simplecloud.info/). IdPs should use the base URL `{% data variables.product.api_url_code %}/scim/v2/organizations/{org}/` for {% data variables.product.product_name %} SCIM endpoints. +These endpoints are used by SCIM-enabled Identity Providers (IdPs) to automate provisioning of {% data variables.product.product_name %} organization membership and are based on version 2.0 of the [SCIM standard](http://www.simplecloud.info/). IdPs should use the base URL `{% data variables.product.rest_url %}/scim/v2/organizations/{org}/` for {% data variables.product.product_name %} SCIM endpoints. {% note %} diff --git a/content/rest/search/search.md b/content/rest/search/search.md index 9d3dfe38be..f64b264494 100644 --- a/content/rest/search/search.md +++ b/content/rest/search/search.md @@ -125,7 +125,7 @@ request would look like this: ``` shell curl -H 'Accept: application/vnd.github.text-match+json' \ -'{% data variables.product.api_url_pre %}/search/issues?q=windows+label:bug \ +'{% data variables.product.rest_url %}/search/issues?q=windows+label:bug \ +language:python+state:open&sort=created&order=asc' ``` diff --git a/content/rest/using-the-rest-api/best-practices-for-using-the-rest-api.md b/content/rest/using-the-rest-api/best-practices-for-using-the-rest-api.md index 8b58913c46..bbd23074d1 100644 --- a/content/rest/using-the-rest-api/best-practices-for-using-the-rest-api.md +++ b/content/rest/using-the-rest-api/best-practices-for-using-the-rest-api.md @@ -75,13 +75,13 @@ Most endpoints return an `etag` header, and many endpoints return a `last-modifi For example, if a previous request returned an `etag` header value of `644b5b0155e6404a9cc4bd9d8b1ae730`, you can use the `if-none-match` header in a future request: ```shell -curl {% data variables.product.api_url_pre %}/meta --include --header 'if-none-match: "644b5b0155e6404a9cc4bd9d8b1ae730"' +curl {% data variables.product.rest_url %}/meta --include --header 'if-none-match: "644b5b0155e6404a9cc4bd9d8b1ae730"' ``` For example, if a previous request returned a `last-modified` header value of `Wed, 25 Oct 2023 19:17:59 GMT`, you can use the `if-modified-since` header in a future request: ```shell -curl {% data variables.product.api_url_pre %}/repos/github/docs --include --header 'if-modified-since: Wed, 25 Oct 2023 19:17:59 GMT' +curl {% data variables.product.rest_url %}/repos/github/docs --include --header 'if-modified-since: Wed, 25 Oct 2023 19:17:59 GMT' ``` ## Do not ignore errors diff --git a/content/rest/using-the-rest-api/getting-started-with-the-rest-api.md b/content/rest/using-the-rest-api/getting-started-with-the-rest-api.md index f81f04cf1c..4002df2c52 100644 --- a/content/rest/using-the-rest-api/getting-started-with-the-rest-api.md +++ b/content/rest/using-the-rest-api/getting-started-with-the-rest-api.md @@ -313,7 +313,7 @@ Use the `curl` command to make your request. For more information, see [the curl Specify the following options and values in your request: - **`--request` or `-X`** followed by the HTTP method as the value. For more information, see "[HTTP method](#http-method)." -- **`--url`** followed by the full path as the value. The full path is a URL that includes the base URL for the GitHub REST API (`https://api.github.com`) and the path of the endpoint, like this: `{% data variables.product.api_url_code %}/PATH`.{% ifversion ghes %} Replace `HOSTNAME` with the name of {% data variables.location.product_location %}.{% endif %} Replace `PATH` with the path of the endpoint. For more information, see "[Path](#path)." +- **`--url`** followed by the full path as the value. The full path is a URL that includes the base URL for the GitHub REST API (`https://api.github.com`) and the path of the endpoint, like this: `{% data variables.product.rest_url %}/PATH`.{% ifversion ghes %} Replace `HOSTNAME` with the name of {% data variables.location.product_location %}.{% endif %} Replace `PATH` with the path of the endpoint. For more information, see "[Path](#path)." To use query parameters, add a `?` to the end of the path, then append your query parameter name and value in the form `parameter_name=value`. Separate multiple query parameters with `&`. If you need to send an array in the query string, use the query parameter once per array item, and append `[]` after the query parameter name. For example, to provide an array of two repository IDs, use `?repository_ids[]=REPOSITORY_A_ID&repository_ids[]=REPOSITORY_B_ID`. For more information, see "[Query parameters](#query-parameters)." For an example, see "[Example request using query parameters](#example-request-using-query-parameters-1)." - **`--header` or `-H`**: @@ -339,7 +339,7 @@ The ["List public events" endpoint](/rest/activity/events#list-public-events) re ```shell copy curl --request GET \ ---url "{% data variables.product.api_url_code %}/events?per_page=2&page=1" \ +--url "{% data variables.product.rest_url %}/events?per_page=2&page=1" \ --header "Accept: application/vnd.github+json" \ --header "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/events @@ -362,7 +362,7 @@ The following example uses the "[Create an issue](/rest/issues/issues#create-an- ```shell copy curl \ --request POST \ ---url "{% data variables.product.api_url_code %}/repos/{% ifversion ghes %}REPO-OWNER/REPO-NAME{% else %}octocat/Spoon-Knife{% endif %}/issues" \ +--url "{% data variables.product.rest_url %}/repos/{% ifversion ghes %}REPO-OWNER/REPO-NAME{% else %}octocat/Spoon-Knife{% endif %}/issues" \ --header "Accept: application/vnd.github+json" \ --header "X-GitHub-Api-Version: 2022-11-28" \ --header "Authorization: Bearer YOUR-TOKEN" \ @@ -402,11 +402,11 @@ Create an access token to authenticate your request. You can save your token and ### 4. Make a request with Octokit.js 1. Import `octokit` in your script. For example, `import { Octokit } from "octokit";`. For other ways to import `octokit`, see [the Octokit.js README](https://github.com/octokit/octokit.js/#readme). -1. Create an instance of `Octokit` with your token.{% ifversion ghes %} Set the base URL to `{% data variables.product.api_url_code %}`. Replace `HOSTNAME` with the name of {% data variables.location.product_location %}.{% endif %} Replace `YOUR-TOKEN` with your token. +1. Create an instance of `Octokit` with your token.{% ifversion ghes %} Set the base URL to `{% data variables.product.rest_url %}`. Replace `HOSTNAME` with the name of {% data variables.location.product_location %}.{% endif %} Replace `YOUR-TOKEN` with your token. ```javascript copy const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: 'YOUR-TOKEN' }); ``` @@ -653,7 +653,7 @@ For example, you can use `>` to redirect the response to a file. In the followin ```shell copy curl --request GET \ ---url "{% data variables.product.api_url_code %}/repos/REPO-OWNER/REPO-NAME/issues?per_page=2" \ +--url "{% data variables.product.rest_url %}/repos/REPO-OWNER/REPO-NAME/issues?per_page=2" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer YOUR-TOKEN" > data.json ``` diff --git a/content/rest/using-the-rest-api/rate-limits-for-the-rest-api.md b/content/rest/using-the-rest-api/rate-limits-for-the-rest-api.md index dc5777c7de..4517f8d1f1 100644 --- a/content/rest/using-the-rest-api/rate-limits-for-the-rest-api.md +++ b/content/rest/using-the-rest-api/rate-limits-for-the-rest-api.md @@ -57,7 +57,7 @@ Primary rate limits for OAuth access tokens generated by a {% data variables.pro OAuth apps can also use their client ID and client secret to fetch public data. For example: ```shell -curl -u YOUR_CLIENT_ID:YOUR_CLIENT_SECRET -I {% data variables.product.api_url_pre %}/meta +curl -u YOUR_CLIENT_ID:YOUR_CLIENT_SECRET -I {% data variables.product.rest_url %}/meta ``` For these requests, the rate limit is 5,000 requests per hour per {% data variables.product.prodname_oauth_app %}. If the app is owned by a {% data variables.product.prodname_ghe_cloud %} organization, the rate limit is 15,000 requests per hour. diff --git a/content/rest/using-the-rest-api/timezones-and-the-rest-api.md b/content/rest/using-the-rest-api/timezones-and-the-rest-api.md index 58e8756d7c..fef9f2663e 100644 --- a/content/rest/using-the-rest-api/timezones-and-the-rest-api.md +++ b/content/rest/using-the-rest-api/timezones-and-the-rest-api.md @@ -34,7 +34,7 @@ An example of this is the API to manage commits. For more information, see "[AUT It is possible to supply a `Time-Zone` header, which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). ```shell -curl -H "Time-Zone: Europe/Amsterdam" -X POST {% data variables.product.api_url_pre %}/repos/github-linguist/linguist/contents/new_file.md +curl -H "Time-Zone: Europe/Amsterdam" -X POST {% data variables.product.rest_url %}/repos/github-linguist/linguist/contents/new_file.md ``` This means that we generate a timestamp for the moment your API call is made, in the timezone this header defines. diff --git a/content/rest/using-the-rest-api/using-cors-and-jsonp-to-make-cross-origin-requests.md b/content/rest/using-the-rest-api/using-cors-and-jsonp-to-make-cross-origin-requests.md index a8a775ac2f..30bbc9bf45 100644 --- a/content/rest/using-the-rest-api/using-cors-and-jsonp-to-make-cross-origin-requests.md +++ b/content/rest/using-the-rest-api/using-cors-and-jsonp-to-make-cross-origin-requests.md @@ -22,7 +22,7 @@ Here's a sample request sent from a browser hitting `http://example.com`: ```shell -$ curl -I {% data variables.product.api_url_pre %} -H "Origin: http://example.com" +$ curl -I {% data variables.product.rest_url %} -H "Origin: http://example.com" HTTP/2 302 Access-Control-Allow-Origin: * Access-Control-Expose-Headers: ETag, Link, x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval @@ -31,7 +31,7 @@ Access-Control-Expose-Headers: ETag, Link, x-ratelimit-limit, x-ratelimit-remain This is what the CORS preflight request looks like: ```shell -$ curl -I {% data variables.product.api_url_pre %} -H "Origin: http://example.com" -X OPTIONS +$ curl -I {% data variables.product.rest_url %} -H "Origin: http://example.com" -X OPTIONS HTTP/2 204 Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With @@ -46,7 +46,7 @@ You can send a `?callback` parameter to any GET call to have the results wrapped in a JSON function. This is typically used when browsers want to embed {% data variables.product.product_name %} content in web pages and avoid cross-domain problems. The response includes the same data output as the regular API, plus the relevant HTTP Header information. ```shell -$ curl {% data variables.product.api_url_pre %}?callback=foo +$ curl {% data variables.product.rest_url %}?callback=foo > /**/foo({ > "meta": { @@ -55,7 +55,7 @@ $ curl {% data variables.product.api_url_pre %}?callback=foo > "x-ratelimit-remaining": "4966", > "x-ratelimit-reset": "1372700873", > "Link": [ // pagination headers and other links -> ["{% data variables.product.api_url_pre %}?page=2", {"rel": "next"}] +> ["{% data variables.product.rest_url %}?page=2", {"rel": "next"}] > ] > }, > "data": { @@ -78,7 +78,7 @@ function foo(response) { } var script = document.createElement('script'); -script.src = '{% data variables.product.api_url_code %}?callback=foo'; +script.src = '{% data variables.product.rest_url %}?callback=foo'; document.getElementsByTagName('head')[0].appendChild(script); diff --git a/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md b/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md index f42c741325..c304fd7fac 100644 --- a/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md +++ b/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md @@ -96,7 +96,7 @@ For example, this script gets all of the issues from the `octocat/Spoon-Knife` r import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}", + baseUrl: "{% data variables.product.rest_url %}", {% endif %}}); const data = await octokit.paginate("GET /repos/{owner}/{repo}/issues", { @@ -123,7 +123,7 @@ The `getPaginatedData` function makes a request to an endpoint with `octokit.req import { Octokit } from "octokit"; const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}", + baseUrl: "{% data variables.product.rest_url %}", {% endif %}}); async function getPaginatedData(url) { diff --git a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-github-app-webhook.md b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-github-app-webhook.md index 7a29a8a474..7bdc61cbb1 100644 --- a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-github-app-webhook.md +++ b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-github-app-webhook.md @@ -133,7 +133,7 @@ async function checkAndRedeliverWebhooks() { appId: APP_ID, privateKey: PRIVATE_KEY,{% ifversion ghes %} Octokit: Octokit.defaults({ - baseUrl: "{% data variables.product.api_url_code %}", + baseUrl: "{% data variables.product.rest_url %}", }),{% endif %} }); @@ -141,7 +141,7 @@ async function checkAndRedeliverWebhooks() { // // This will be used to update the configuration variable that stores the last time that this script ran. const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: TOKEN, }); diff --git a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-repository-webhook.md b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-repository-webhook.md index 75d89665fe..7163b1b200 100644 --- a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-repository-webhook.md +++ b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-repository-webhook.md @@ -127,7 +127,7 @@ async function checkAndRedeliverWebhooks() { // Create an instance of `Octokit` using the token{% ifversion ghes %} and hostname{% endif %} values that were set in the {% data variables.product.prodname_actions %} workflow. const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: TOKEN, }); diff --git a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-an-organization-webhook.md b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-an-organization-webhook.md index b05d958cfd..b34a3a78b0 100644 --- a/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-an-organization-webhook.md +++ b/content/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-an-organization-webhook.md @@ -124,7 +124,7 @@ async function checkAndRedeliverWebhooks() { // Create an instance of `Octokit` using the token{% ifversion ghes %} and hostname{% endif %} values that were set in the {% data variables.product.prodname_actions %} workflow. const octokit = new Octokit({ {% ifversion ghes %} - baseUrl: "{% data variables.product.api_url_code %}",{% endif %} + baseUrl: "{% data variables.product.rest_url %}",{% endif %} auth: TOKEN, }); diff --git a/content/webhooks/webhook-events-and-payloads.md b/content/webhooks/webhook-events-and-payloads.md index 456412d051..c7638a7851 100644 --- a/content/webhooks/webhook-events-and-payloads.md +++ b/content/webhooks/webhook-events-and-payloads.md @@ -71,7 +71,7 @@ You can choose to have payloads delivered in JSON format (`application/json`) or > { > "action": "opened", > "issue": { -> "url": "{% data variables.product.api_url_pre %}/repos/octocat/Hello-World/issues/1347", +> "url": "{% data variables.product.rest_url %}/repos/octocat/Hello-World/issues/1347", > "number": 1347, > ... > }, diff --git a/data/reusables/apps/generate-installation-access-token.md b/data/reusables/apps/generate-installation-access-token.md index d05e73e985..9c0ebdde1a 100644 --- a/data/reusables/apps/generate-installation-access-token.md +++ b/data/reusables/apps/generate-installation-access-token.md @@ -13,7 +13,7 @@ ```shell curl --request POST \ - --url "{% data variables.product.api_url_pre %}/app/installations/INSTALLATION_ID/access_tokens" \ + --url "{% data variables.product.rest_url %}/app/installations/INSTALLATION_ID/access_tokens" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer JWT" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" diff --git a/data/reusables/apps/user-access-token-example-request.md b/data/reusables/apps/user-access-token-example-request.md index 82352ae1fd..cee36a7b87 100644 --- a/data/reusables/apps/user-access-token-example-request.md +++ b/data/reusables/apps/user-access-token-example-request.md @@ -2,7 +2,7 @@ ```shell curl --request GET \ - --url "{% data variables.product.api_url_pre %}/user" \ + --url "{% data variables.product.rest_url %}/user" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer USER_ACCESS_TOKEN" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" diff --git a/data/variables/product.yml b/data/variables/product.yml index 4622667f1e..0593a75fe2 100644 --- a/data/variables/product.yml +++ b/data/variables/product.yml @@ -299,9 +299,8 @@ raw_github_com: >- current-340-version: '11.10.354' # Developer site product variables -# Use this inside command-line code blocks -api_url_pre: >- - {% ifversion fpt or ghec %}https://api.github.com{% elsif ghes %}http(s)://HOSTNAME/api/v3{% endif %} +rest_url: >- + {% ifversion fpt or ghec %}https://api.github.com{% elsif ghes %}http(s)://HOSTNAME/api/v3{% endif %} # Use this inside command-line code blocks # Enterprise OAuth paths that don't include "/graphql" or "/api/v3" oauth_host_code: >- @@ -312,12 +311,5 @@ device_authorization_url: >- {%- elsif ghes %} `http(s)://HOSTNAME/login/device` {%- endif %} -# Use this all other code blocks -api_url_code: >- - {% ifversion fpt or ghec %}https://api.github.com{% elsif ghes %}http(s)://HOSTNAME/api/v3{% endif %} -# Use this inside command-line code blocks -graphql_url_pre: >- - {% ifversion fpt or ghec %}https://api.github.com/graphql{% elsif ghes %}http(s)://HOSTNAME/api/graphql{% endif %} -# Use this all other code blocks -graphql_url_code: >- +graphql_url: >- {% ifversion fpt or ghec %}https://api.github.com/graphql{% elsif ghes %}http(s)://HOSTNAME/api/graphql{% endif %}