---
id: "T:cAlgo.API.Http"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/HTTP/Http/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Http (interface)

The `Https` interface contains the methods necessary for sending HTTP requests.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: No request is sent. The response, or the callback, has IsSuccessful false, StatusCode 403 and Body null. No exception is thrown.

## Definition

```csharp
public interface Http
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo.Robots;

public partial class Test : Robot
{
    protected override void OnStart()
    {
        var response = Http.Get("https://api.restful-api.dev/objects");

        if (!response.IsSuccessful)
        {
            Print("HTTP request failed");
            return;
        }

        Print(response.Body);
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        response = api.Http.Get("https://api.restful-api.dev/objects")

        if response.IsSuccessful == False:
            print("HTTP request failed")
            return

        print(response.Body)
```

config.json:

```json
{
  "AccessRights": "None"
}
```

C#:

```csharp
using cAlgo.API;

namespace cAlgo.Robots;

public partial class Test : Robot
{
    protected override void OnStart()
    {
        var request = new HttpRequest(new("https://api.restful-api.dev/objects"));

        request.Headers.Add("Authorization", "Bearer token");

        var response = Http.Send(request);

        if (!response.IsSuccessful)
        {
            Print("HTTP request failed");
            return;
        }

        Print(response.Body);
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *
from System import Uri

class Test():
    def on_start(self):
        request = HttpRequest(Uri("https://api.restful-api.dev/objects"))
        request.Headers.Add("Authorization", "Bearer token")

        response = api.Http.Send(request)

        if response.IsSuccessful == False:
            print("HTTP request failed")
            return

        print(response.Body)
```

config.json:

```json
{
  "AccessRights": "None"
}
```

## Methods

- `HttpResponse Get(Uri uri)` — Performs a GET request to the specified URI. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/Get/index.md)
- `HttpResponse Get(string uri)` — Performs a GET request to the specified URI. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/Get/index.md)
- `void GetAsync(Uri uri, Action<HttpResponse> callback)` — Performs a GET request to the specified URI asynchronously. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/GetAsync/index.md)
- `void GetAsync(string uri, Action<HttpResponse> callback)` — Performs a GET request to the specified URI asynchronously. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/GetAsync/index.md)
- `HttpResponse Send(HttpRequest request)` — Performs a request to the specified URI. The request method depends on the value of the request.Method property. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/Send/index.md)
- `void SendAsync(HttpRequest request, Action<HttpResponse> callback)` — Performs a request to the specified URI. The request method depends on the value of the request.Method property. [details](https://help.ctrader.com/ctrader-algo/references/HTTP/Http/SendAsync/index.md)

