Qaynaq LABS · TOOLS

CURL → CODE · DELETE · BEARER

cURL → 10 languages

DELETE api.linear.app · body: json · secrets replaced with env vars.

Source cURL
curl -X DELETE https://api.linear.app/graphql -H "Authorization: YOUR_LINEAR_API_KEY" -H "Content-Type: application/json" -d '{"query":"mutation { deleteIssue(id: \"issue_id\") { success } }","variables":{}}'

Python · requests

import os
import requests

url = "https://api.linear.app/graphql"
headers = {
    "Authorization": f"Bearer {os.environ['LINEAR_API_KEY']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { deleteIssue(id: \"issue_id\") { success } }",
    "variables": {}
}

response = requests.delete(url, headers=headers, json=data)
if response.status_code >= 400:
    print(response.text)
else:
    print(response.json())

Python · httpx

import os
import httpx

url = "https://api.linear.app/graphql"
headers = {
    "Authorization": f"Bearer {os.environ['LINEAR_API_KEY']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { deleteIssue(id: \"issue_id\") { success } }",
    "variables": {}
}

with httpx.Client() as client:
    response = client.delete(url, headers=headers, json=data)
    if response.status_code >= 400:
        print(response.text)
    else:
        print(response.json())

Node.js · fetch

import fetch from 'node-fetch';
import { env } from 'process';

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${env.LINEAR_API_KEY}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { deleteIssue(id: "issue_id") { success } }',
  variables: {}
};

fetch(url, {
  method: 'DELETE',
  headers,
  body: JSON.stringify(data)
})
  .then(async response => {
    if (response.status >= 400) {
      console.log(await response.text());
    } else {
      console.log(await response.json());
    }
  })
  .catch(err => console.error(err));

Node.js · axios

import axios from 'axios';
import { env } from 'process';

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${env.LINEAR_API_KEY}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { deleteIssue(id: "issue_id") { success } }',
  variables: {}
};

axios.delete(url, { headers, data })
  .then(response => {
    if (response.status >= 400) {
      console.log(response.data);
    } else {
      console.log(response.data);
    }
  })
  .catch(err => console.error(err));

Go · net/http

package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

type requestBody struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`
}

func main() {
	url := "https://api.linear.app/graphql"
	apiKey := os.Getenv("LINEAR_API_KEY")
	if apiKey == "" {
		log.Fatal("LINEAR_API_KEY environment variable not set")
	}

	body := requestBody{
		Query:     "mutation { deleteIssue(id: \"issue_id\") { success } }",
		Variables: map[string]interface{}{},
	}
	jsonBody, err := json.Marshal(body)
	if err != nil {
		log.Fatal(err)
	}

	req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(jsonBody))
	if err != nil {
		log.Fatal(err)
	}

	req.Header.Set("Authorization", "Bearer "+apiKey)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode >= 400 {
		body, _ := io.ReadAll(resp.Body)
		fmt.Println(string(body))
	} else {
		body, _ := io.ReadAll(resp.Body)
		fmt.Println(string(body))
	}
}

PHP · cURL

<?php

$url = 'https://api.linear.app/graphql';
$apiKey = getenv('LINEAR_API_KEY');
if (empty($apiKey)) {
    die('LINEAR_API_KEY environment variable not set');
}

$headers = [
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json'
];

$data = [
    'query' => 'mutation { deleteIssue(id: "issue_id") { success } }',
    'variables' => []
];

$options = [
    'http' => [
        'method' => 'DELETE',
        'header' => $headers,
        'content' => json_encode($data),
        'ignore_errors' => true
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);

if ($http_response_header[0] >= 400) {
    echo $response;
} else {
    echo $response;
}

Ruby · net/http

require 'net/http'
require 'json'
require 'uri'

url = URI.parse('https://api.linear.app/graphql')
api_key = ENV.fetch('LINEAR_API_KEY')

headers = {
  'Authorization' => "Bearer #{api_key}",
  'Content-Type' => 'application/json'
}

data = {
  query: 'mutation { deleteIssue(id: "issue_id") { success } }',
  variables: {}
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url.request_uri, headers)
request.body = data.to_json

response = http.request(request)

if response.code.to_i >= 400
  puts response.body
else
  puts response.body
end

Swift · URLSession

import Foundation

let url = URL(string: "https://api.linear.app/graphql")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer \(ProcessInfo.processInfo.environment["LINEAR_API_KEY"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = [
    "query": "mutation { deleteIssue(id: \"issue_id\") { success } }",
    "variables": [:]
]

request.httpBody = try? JSONSerialization.data(withJSONObject: body)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print(error)
        return
    }
    guard let httpResponse = response as? HTTPURLResponse else {
        print("Invalid response")
        return
    }
    if httpResponse.statusCode >= 400 {
        if let data = data, let responseBody = String(data: data, encoding: .utf8) {
            print(responseBody)
        }
    } else {
        if let data = data, let responseBody = String(data: data, encoding: .utf8) {
            print(responseBody)
        }
    }
}

task.resume()
RunLoop.main.run()

Rust · reqwest

use reqwest::blocking::Client;
use std::collections::HashMap;
use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://api.linear.app/graphql";
    let api_key = env::var("LINEAR_API_KEY")?;

    let client = Client::new();
    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert(
        "Authorization",
        format!("Bearer {}", api_key).parse()?,
    );
    headers.insert(
        "Content-Type",
        "application/json".parse()?,
    );

    let body: HashMap<&str, &str> = HashMap::from([
        ("query", "mutation { deleteIssue(id: \"issue_id\") { success } }"),
        ("variables", ""),
    ]);

    let response = client
        .delete(url)
        .headers(headers)
        .json(&body)
        .send()?;

    if response.status().is_client_error() || response.status().is_server_error() {
        println!("{}", response.text()?);
    } else {
        println!("{}", response.text()?);
    }

    Ok(())
}

C# · HttpClient

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var url = "https://api.linear.app/graphql";
        var apiKey = Environment.GetEnvironmentVariable("LINEAR_API_KEY");
        if (string.IsNullOrEmpty(apiKey))
        {
            Console.WriteLine("LINEAR_API_KEY environment variable not set");
            return;
        }

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        var body = new
        {
            query = "mutation { deleteIssue(id: \"issue_id\") { success } }",
            variables = new { }
        };

        var response = await client.DeleteAsync(url, new StringContent(JsonSerializer.Serialize(body)));
        if (!response.IsSuccessStatusCode)
        {
            var errorContent = await response.Content.ReadAsStringAsync();
            Console.WriteLine(errorContent);
        }
        else
        {
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Translation notes

  • All implementations use the idiomatic HTTP client for each language.
  • Bearer token is read from environment variable LINEAR_API_KEY to avoid hardcoding.
  • Error handling checks status code >= 400 and prints the response body.
  • JSON bodies are constructed as objects/dicts, not raw strings.
  • Python implementations use requests/httpx, Node.js uses fetch/axios, Go uses net/http, PHP uses stream context, Ruby uses Net::HTTP, Swift uses URLSession, Rust uses reqwest, C# uses HttpClient.

Common pitfalls when porting

  • Forgetting to set the Authorization header with the Bearer token.
  • Not handling the environment variable for the API key, leading to hardcoded secrets.
  • Incorrectly serializing the JSON body (e.g., using raw strings instead of objects).
  • Ignoring SSL/TLS verification in environments where it might be disabled (e.g., Go, Python).
  • Assuming the API key is always present in the environment variable without validation.

About cURL → code translation

cURL is the lingua franca of API documentation: every vendor docs page ships a cURL snippet you can paste into a terminal and immediately see the API working. Translating that into your actual application code shouldn't be a 20-minute Stack-Overflow safari, but without a good translator it usually is.

Qaynaq Labs' cURL → code tool reads the full command — method, URL, headers, query params, body type, and auth — and emits idiomatic client code in 10 languages. Authentication goes through environment variables by default, request bodies become language-native data structures (not raw JSON strings), and minimal error handling is included.

Frequently asked

Why is the Bearer token read from an environment variable?

Reading secrets from environment variables is a security best practice to avoid hardcoding sensitive data in source code or version control.

Can I use a different HTTP client library in these languages?

Yes, but the provided implementations use the most idiomatic and widely adopted libraries for each language to ensure consistency and maintainability.

How do I handle pagination or large responses in these clients?

The provided implementations focus on the basic request. For pagination or large responses, you would typically use streaming or chunked reading methods provided by the respective libraries.