import requests
user_id = 1 # User ID
user_req = requests.get(f"https://users.roblox.com/v1/users/{user_id}")
user_data = user_req.json()
print("Name:", user_data["name"])
print("Display Name:", user_data["displayName"])
print("User ID:", user_data["id"])
print("Description:")
print(user_data["description"])
Your first request
At this point, you’re ready to use most of the endpoints that take in GET requests on these domains, as they won’t require authentication, like users.roblox.com/v1/users/userId. This endpoint returns response data that looks like this.
{
"description": "Welcome to the Roblox profile! This is where you can check out the newest items in the...",
"created": "2006-02-27T21:06:40.3Z",
"isBanned": false,
"id": 1,
"name": "ROBLOX",
"displayName": "ROBLOX"
}
You’ll probably use this endpoint along with other endpoints on users.roblox.com
quite a lot, as they are extremely useful for grabbing information about a user.
# Uses the http.rb gem. Run "gem install http" on your terminal to install it
require "http"
require "json"
USER_ID = 1
response = HTTP.get("https://users.roblox.com/v1/users/#{USER_ID}")
body = JSON.parse(response.body)
puts "Username: #{body["name"]}"
puts "Display name: #{body["displayName"]}"
puts "User ID: #{body["id"]}"
puts "Description: #{body["description"]}"
/*
Cargo.toml dependencies:
reqwest = { version = "0.11.4" }
tokio = { version = "1.11.0", features = ["macros", "rt-multi-thread"]}
serde_json = { vesion = "1.0.67"}
*/
use reqwest::get;
use serde_json::{from_str, Value};
const USER_ID: i64 = 1;
#[tokio::main]
async fn main() {
let response = get(format!("https://users.roblox.com/v1/users/{}", USER_ID))
.await
.unwrap()
.text()
.await
.unwrap();
let body: Value = from_str(&response).unwrap();
println!("Username: {}", body["name"].as_str().unwrap());
println!("Display name: {}", body["displayName"].as_str().unwrap());
println!("User ID: {}", body["id"].as_i64().unwrap());
println!("Description: {}", body["description"].as_str().unwrap());
}
// Uses the Netwonsoft.Json package. Run "dotnet add package Newtonsoft.Json --version 13.0.1" on your terminal to install it.
using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
namespace your_first_request
{
class Program
{
private const long USER_ID = 1;
static void Main(string[] args)
{
WebResponse response = HttpWebRequest.Create($"https://users.roblox.com/v1/users/{USER_ID}")
.GetResponse();
JObject body = JObject.Parse(
new StreamReader(
response.GetResponseStream()
).ReadToEnd()
);
Console.WriteLine($"Username: {body["name"]}");
Console.WriteLine($"Display name: {body["displayName"]}");
Console.WriteLine($"User ID: {body["id"]}");
Console.WriteLine($"Description: {body["description"]}");
}
}
}
// npm install node-fetch
import fetch from "node-fetch";
const USER_ID = 1;
const response = await fetch(`https://users.roblox.com/v1/users/${USER_ID}`);
const body = await response.json();
console.log(`Username: ${body["name"]}`);
console.log(`Display name: ${body["displayName"]}`);
console.log(`User ID: ${body["id"]}`);
console.log(`Description: ${body["description"]}`);
const USER_ID = 1;
const response = await fetch(`https://users.roblox.com/v1/users/${USER_ID}`);
const body = await response.json();
console.log(`Username: ${body["name"]}`);
console.log(`Display name: ${body["displayName"]}`);
console.log(`User ID: ${body["id"]}`);
console.log(`Description: ${body["description"]}`);
// Uses the Netwonsoft.Json package. Run "dotnet add package Newtonsoft.Json --version 13.0.1" on your terminal to install it.
open System.Net.Http
open Newtonsoft.Json.Linq
[<EntryPoint>]
let main _ =
async {
use client = new HttpClient()
let! response =
client.GetStringAsync("https://users.roblox.com/v1/users/1")
|> Async.AwaitTask
let parsedBody = JObject.Parse response
printfn $"""Username: {parsedBody.["name"]}"""
printfn $"""Display name: {parsedBody.["displayName"]}"""
printfn $"""User ID: {parsedBody.["id"]}"""
printfn $"""Description: {parsedBody.["description"]}"""
}
|> Async.RunSynchronously
0
This article is a part of the Accessing the Roblox API series.
< Understanding documentation | Your first request | Handling errors >