Get Folders

πŸ“ Get Folders

Get the list of your folders.

import requests

api_key = 'your_api_key_here'  # Replace with your actual API key

# Set up the headers, including the API key
headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {api_key}',
    'Accept': 'application/json'
}

url = f"https://api.tor.app/developer/folders"


response = requests.get(url, headers=headers)

response_json = response.json()

print(response_json)

const axios = require('axios');

const apiKey = 'your_api_key_here'; // Replace with your actual API key

// Set up the headers, including the API key
const headers = {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${apiKey}`,
    'Accept': 'application/json'
};

const url = "https://api.tor.app/developer/folders";

axios.get(url, { headers })
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error(error.response ? error.response.data : error.message);
    });



import okhttp3.*;
import org.json.JSONObject;

public class GetFolders {
    private static final String API_KEY = "your_api_key_here"; // Replace with your actual API key

    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient();

        String url = "https://api.tor.app/developer/folders";

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", "Bearer " + API_KEY)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                String responseData = response.body().string();
                JSONObject json = new JSONObject(responseData);
                System.out.println(json.toString(2));
            } else {
                System.out.println("Request failed: " + response.code());
            }
        }
    }
}


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

public class Program
{
    private static readonly string apiKey = "your_api_key_here"; // Replace with your actual API key

    public static async Task Main()
    {
        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");

        var url = "https://api.tor.app/developer/folders";
        var response = await client.GetAsync(url);

        if (response.IsSuccessStatusCode)
        {
            var responseJson = await response.Content.ReadAsStringAsync();
            var data = JsonSerializer.Deserialize<JsonDocument>(responseJson);
            Console.WriteLine(data.RootElement.ToString());
        }
        else
        {
            Console.WriteLine($"Request failed with status: {response.StatusCode}");
        }
    }
}


package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

const (
	apiKey = "your_api_key_here" // Replace with your actual API key
)

func main() {
	url := "https://api.tor.app/developer/folders"

	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", "Bearer "+apiKey)
	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Accept", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Request failed:", err)
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode == http.StatusOK {
		var result map[string]interface{}
		json.NewDecoder(resp.Body).Decode(&result)
		fmt.Println(result)
	} else {
		fmt.Printf("Request failed with status: %d\n", resp.StatusCode)
	}
}


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

api_key = "your_api_key_here" # Replace with your actual API key

url = URI("https://api.tor.app/developer/folders")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"

response = http.request(request)
if response.code.to_i == 200
    response_json = JSON.parse(response.body)
    puts response_json
else
    puts "Request failed with status: #{response.code}"
end


<?php
$apiKey = "your_api_key_here"; // Replace with your actual API key

$url = "https://api.tor.app/developer/folders";

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

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode == 200) {
    $responseJson = json_decode($response, true);
    print_r($responseJson);
} else {
    echo "Request failed with status: $httpCode\n";
}
?>


import okhttp3.OkHttpClient
import okhttp3.Request

fun main() {
    val apiKey = "your_api_key_here" // Replace with your actual API key

    val client = OkHttpClient()
    val url = "https://api.tor.app/developer/folders"

    val request = Request.Builder()
        .url(url)
        .addHeader("Authorization", "Bearer $apiKey")
        .addHeader("Content-Type", "application/json")
        .addHeader("Accept", "application/json")
        .build()

    client.newCall(request).execute().use { response ->
        if (response.isSuccessful) {
            println(response.body()?.string())
        } else {
            println("Request failed with status: ${response.code()}")
        }
    }
}


import Foundation

let apiKey = "your_api_key_here" // Replace with your actual API key

let url = URL(string: "https://api.tor.app/developer/folders")!
var request = URLRequest(url: url)
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else {
        print("Request failed:", error ?? "Unknown error")
        return
    }
    
    if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 {
        let responseJson = try? JSONSerialization.jsonObject(with: data, options: [])
        print(responseJson ?? "Failed to parse response")
    } else {
        print("Request failed with status:", (response as? HTTPURLResponse)?.statusCode ?? 0)
    }
}
task.resume()


import 'dart:convert';
import 'dart:io';

void main() async {
  const apiKey = "your_api_key_here"; // Replace with your actual API key

  final url = Uri.parse("https://api.tor.app/developer/folders");
  final request = await HttpClient().getUrl(url)
    ..headers.set("Authorization", "Bearer $apiKey")
    ..headers.set("Content-Type", "application/json")
    ..headers.set("Accept", "application/json");

  final response = await request.close();
  if (response.statusCode == 200) {
    final responseBody = await response.transform(utf8.decoder).join();
    final responseJson = jsonDecode(responseBody);
    print(responseJson);
  } else {
    print("Request failed with status: ${response.statusCode}");
  }
}