> Use the canonical URL for citations. For the complete Predict API documentation index, fetch https://docs.staging.trypredict.com/llms.txt.

# Get account by username

GET https://api.staging.trypredict.com/v1/accounts/by-username/{username}

Resolve a Predict account by its public username, including its Hyperliquid address, profile, and account relationships.

Reference: https://docs.staging.trypredict.com/api-reference/account/get-account-by-username

## Request

### Path parameters

- `username` (string, required)

## Response

### 200

OK

- `account_type` (enum, optional) — Allowed value for account type.
  - Allowed values: `main`, `subaccount`
- `subaccounts` (list of AccountRef, optional)
- `address` (string, optional) — EVM wallet address encoded as a 0x-prefixed hexadecimal string.
- `username` (string, optional)
- `image_url` (string, optional) — Absolute URL for the referenced resource.
- `hyperliquid_name` (string, optional)
- `parent` (AccountRef, optional)

## Errors

### 400 Bad Request Error

The request is malformed or violates a field constraint.

- `error` (RESTError, required)

### 404 Not Found Error

The requested resource does not exist.

- `error` (RESTError, required)

### 405 Method Not Allowed Error

The HTTP method is not allowed on this path.

- `error` (RESTError, required)

### 500 Internal Server Error

The server could not complete the request.

- `error` (RESTError, required)

### 503 Service Unavailable Error

A required dependency is temporarily unavailable.

- `error` (RESTError, required)

## Types

### AccountRef

- `address` (string, optional) — EVM wallet address encoded as a 0x-prefixed hexadecimal string.
- `username` (string, optional)
- `image_url` (string, optional) — Absolute URL for the referenced resource.
- `hyperliquid_name` (string, optional)
- `account_type` (enum, optional) — Always set. Zero is main; every stored row has a real type.
  - Allowed values: `main`, `subaccount`

### RESTError

- `code` (integer, required) — HTTP status code returned with the response.
- `status` (enum, required) — Stable canonical status name suitable for programmatic handling.
  - Allowed values: `INVALID_ARGUMENT`, `UNAUTHENTICATED`, `PERMISSION_DENIED`, `NOT_FOUND`, `METHOD_NOT_ALLOWED`, `ALREADY_EXISTS`, `RESOURCE_EXHAUSTED`, `INTERNAL`, `UNAVAILABLE`, `DEADLINE_EXCEEDED`
- `message` (string, required) — Human-readable explanation that is safe to show to an API caller.
- `details` (list of ErrorDetail, required) — Typed structured context for clients that need to handle the error programmatically.

### ErrorDetail

- `type`: `field_violation` (field_violation)
  - `field` (string, required) — Request field that failed validation.
  - `reason` (string, required) — Stable machine-readable reason for the validation failure.
- `type`: `rate_limit` (rate_limit)
  - `limit` (long, required) — Maximum requests allowed during the rolling window.
  - `reason` (string, required) — Stable machine-readable reason identifying the exhausted policy.
  - `retry_after_seconds` (long, required) — Whole seconds until the exhausted policy has capacity.
  - `scope` (enum, required) — Quota that rejected the request.
    - Allowed values: `endpoint`, `global`
  - `window_seconds` (long, required) — Rolling-window duration in seconds.
- `type`: `dependency` (dependency)
  - `reason` (string, required) — Stable machine-readable reason for the temporary dependency failure.

## Examples

**Response**

```json
{
  "account_type": "main",
  "subaccounts": [
    {
      "address": "string",
      "username": "string",
      "image_url": "string",
      "hyperliquid_name": "string",
      "account_type": "main"
    }
  ],
  "address": "string",
  "username": "string",
  "image_url": "string",
  "hyperliquid_name": "string",
  "parent": {
    "address": "string",
    "username": "string",
    "image_url": "string",
    "hyperliquid_name": "string",
    "account_type": "main"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.staging.trypredict.com/v1/accounts/by-username/username"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.staging.trypredict.com/v1/accounts/by-username/username';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staging.trypredict.com/v1/accounts/by-username/username"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.staging.trypredict.com/v1/accounts/by-username/username")

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

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.staging.trypredict.com/v1/accounts/by-username/username")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.staging.trypredict.com/v1/accounts/by-username/username');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.staging.trypredict.com/v1/accounts/by-username/username");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staging.trypredict.com/v1/accounts/by-username/username")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```