Learn to Code via Tutorials on Repl.it!

← Back to all posts
Repl.it api example
Coder100 (16789)

Hi everyone, so I asked a question on AMA and here is where I am now.


To learn graphQL, go here and maybe you want to search up graphQL tutorial as well on google if you are not familiar with the querying language (it's like JSON but less strict and better)

Ok, now you want to go to the headers tab, and type in this:

  "X-Requested-With": "coder100",

X-requested-with can be anything and referrer IDK about.
Now it's time to do some query-ing!

Query the heck out of there

Now, in the editor, let's get all the information about you

# Write your query or mutation here
  userByUsername(username: "[username]") {
    karma, id, firstName, lastName, bio, isVerified

Interestingly, cycles are called karma like on reddit....repl.it coins? lol


Now, make a bash file on repl.it and copy the CURL code (located in the top right) and paste it in the REPL and click run. Ugly compressed JSON code should be seen (if not an error), and this is where you have to do some things. Where you see the username: "[username]" part, escape it out so it looks like username: \"[username]\". Ok, now go to your favorite JSON beautifier and look at the fruit of your labor.


A REPL of mine is put on this tutorial to show you how awesome graphQL is!


Try to do this in node.js it won't be hard as all the headers necessary are there!

Dart (1185)

This is one of the scenarios where python is just easier

Also cool 1 line post

Coder100 (16789)

Thanks! Hope it won't get flagged because bash commands can only be one line :P I think some of those headers aren't necessary but this is still pretty good. Node.js will be good for this i think since it is synchronous by default. @Zexogon

Warhawk947 (552)

@Zexogon yea mat1's repltalk is much more easier to use

Coder100 (16789)

Fine. I'll show you lol @Warhawk947

MrEconomical (2287)

@Zexogon more like this is one of the scenarios where node.js is just easier

Coder100 (16789)

lol yeah
axios is superior to requests >:) @MrEconomical

abc3354 (225)

Note : I am actually translating mat's api in node.js, it is another way to use the api with graphql under the hood

Coder100 (16789)

publish it on NPM! However I wouldn't recommend using mat's api when you can just use node-fetch for all of the get things @abc3354

abc3354 (225)

I will !
And I am not sure I want to learn graphql lol (maybe a day)

AdCharity (1317)

how do you fetch it with javascript? I assume you use ajax or simply fetch?

Coder100 (16789)

yeah, node-fetch with the appropriate headers. example @AdCharity

Coder100 (16789)

Try not to use my sensitive info but ok @AdCharity

Coder100 (16789)

nvm i commented it out @AdCharity