An async and lightweight C# library for interacting with Replit APIs.
Provides an easy interface for interacting with Replit APIs. Currently distributed packages:
To get started, add the library into your solution with either the NuGet Package Manager
or the dotnet
CLI.
dotnet add package Replit.GraphQL
For the primary classes to become available, import the used namespace.
using Replit.GraphQL;
Warning
Certain actions require you to pass a valid session identifier (connect.sid
) cookie. You can obtain this from the browserDeveloper Tools
while logged in.
Unsure of how to obtain this value? See this guide written by RayhanADev.
If you are on mobile, you can alternatively use this web based form made by IroncladDev.
- Built for
.NET 6
and.NET 7
- Fully async
- Extensive XML documentation
- No external dependencies (uses integrated HTTP and JSON)
- Custom exceptions for advanced catching
- Execute single or bulk Replit GraphQL queries
Under the Example
directory you can find a working demo project that implements this library.
string sid = "s%3Bew5ttAQuBlAANjIh8ABSoTTtZ75-7AbH.ohRBI9wNPwOHED7GLltPBrOS975gxqATe1aL6y%9N3%2Fla";
ReplitGraphQLClient client = new(sid, "Example Application");
string userByUsername = @"
query userByUsername($username: String!) {
user: userByUsername(username: $username) {
id
bio
firstName
lastName
timeCreated
}
}";
User user = (await client.Execute<UserContainer>(userByUsername, new Dictionary<string, object>()
{
{
"username", "akac"
}
}))?.User;
Repl[] repls = (await client.BulkExecute<ReplContainer>(new GraphQLParameters[]
{
new(replByUrl, new() { { "url", "https://replit.com/@amasad/TroubledPersonalBaitware" } }),
new(replByUrl, new() { { "url", "https://replit.com/@amasad/my-fun-new-app" } }),
new(replByUrl, new() { { "url", "https://replit.com/@amasad/comic-sans" } })
}))?.Select(data => data.Repl).ToArray();
Console.WriteLine($"Retrieved {repls.Length} repls back");
foreach (Repl repl in repls) Console.WriteLine($"=> {repl.Title} ({repl.Id}) was created at {repl.TimeCreated}");
- Task<GraphQLContainer[]> BulkExecuteRaw(GraphQLParameters[] parameters, JsonSerializerOptions options = null)
- Task<GraphQLContainer> ExecuteRaw(string query, Dictionary<string, object> variables = null, string operationName = null, JsonSerializerOptions options = null)
- Task<T[]> BulkExecute(GraphQLParameters[] parameters, bool suppressErrors = false, JsonSerializerOptions options = null)
- Task<T> Execute(string query, Dictionary<string, object> variables = null, bool suppressErrors = false, string operationName = null, JsonSerializerOptions options = null)