is there a api for replit
Replit isn’t the only site using GraphQL, I think we need to stop giving that impression XD
Maybe have them learn GraphQL first, before applying it to Replit? https://graphql.org/learn/
to follow, these are my fav resources:
How can i use the replit api.
ok, I going to learn it
After you’ve learned a bit about how gql works:
You need to send a POST request to https://replit.com/graphql, and the body needs to be a JSON object with the query and/or variables. Special headers are also required. For authenticated requests, you’ll need your SID cookie. You can learn how to get that here. Here’s a Node.js example, using fetch, to get some information about a user from their username
const fetch = require('@replit/node-fetch');
fetch('https://replit.com/graphql', {
method: 'POST',
body: JSON.stringify({
query: 'query UserByUsername($username: String!) {userByUsername(username: $username) {id username bio timeCreated}}',
variables: {
username: 'PikachuB2005'
}
}),
headers: {
'X-Requested-With': 'replit',
'Referrer': 'https://replit.com',
'User-Agent': 'Mozilla/5.0',
'Content-Type': 'application/json',
'Cookie': 'connect.sid=YourSIDCookieHere'
}
}).then((res) => res.json().then((json) => {
console.log(json.data);
}))
The @replit/node-fetch
dependency isn’t needed in nodejs 18 (or 16 if you provide the right flag), because fetch
is now part of Node’s standard library
I’ve never really bothered to learn about this stuff, one question I have is; does your SID ever change or reset? If not, do you automate collecting their SID somehow for projects requiring Replit GraphQL.
I think it changes when you log out and back in.
Yeah, that’s what I thought… So then how would you create automated things if the SID becomes invalid? Oh… Wait, would you use a scraping tool like Selenium?
I pretty much never log out and back in so…
True, me neither… But I might like log in on a different device or something
In which case I do believe you are just issued another SID, as I do believe SIDs are intended to be per-device.
You can just make a login request to Replit with yur username/password/captcha to get another SID. Ray’s login package
Ok, Thank you, I marked this as the solution
Is there a api for replit forums
yup
I found some apis for the replit forum
https://ask.replit.com/topics/created-by/Mrdev88.json
https://ask.replit.com/user_actions.json?offset=0&username=Mrdev88
https://ask.replit.com/user_actions.json?offset=0&username=Mrdev88&filter=4,5
That exists but to acess a lot of endpoints with code you need an API key witch we no longer issue