ReplFiles! ~ Fetch ANY File from a Public Repl
Hiya! It's Ray. Here's
Fetch ANY File from a Public Repl
This is perhaps one of the more useful API's I've made for the Replit Community. I myself have always wanted to get files on a Repl, but (to my knowledge) there is no API endpoint or query to get files...
That's when @stungeye asked on the Feedback board for a tool to archive all Repls a Replit user has made. I set out to make such a tool and ended up with ArchiveIt. It fetches a
.zip file available for every Repl at
/@username/slug.zip, unzips the file to a folder, and then zips up the full folder of Repls.
It then dawned on me that I had access to EVERY file from those Repls. The NodeJS package Adm-Zip also makes accessing the content of all these files dirt simple. This trail led me to make this simple API that allows you to access any file, on any public Repl!
OKAY storytime over, here's how to use it :)
The API has two endpoints:
The former is used for fetching a specific file. It returns an array with the file contents.
You can also attach a
raw=1 query to output the raw text without stringifying and nonsense.
The latter is used to get ALL files from a Repl. It returns an array with all files in a Repl. This uses a
.gitignore file if present to filter out files.
and it's as simple as that! If you have any suggestions or ideas let me know in the comments below. Until next time :D.
P.S. ReplAPI.it integration with this API is on it's way >:)
but here's the question:
what if the user didn't rename the file and replit, as the bug still exists, doesn't get the file?
but you realize you can use this too right??
https://replbox.repl.it/data/web_hosting_1/tcsirvine_pgur/<repl slug>/<file name>
Hey @ch1ck3n, you seem to be very versed in poking around Replit (actually the entire Blog class exists solely because of you LOL!) and you're really good at using Node/Web. Are you interested in joining the ReplAPI.it Project? I'm looking to get more people in on the project and I wanted to ask you first.
or if you prefer reading dilapitated ES5: https://github.com/RayhanADev/ReplAPI.it/blob/main/commonjs/src/classes/Blog.js
@RoBlockHead are you asking for a use case?
Well say I wanted to get a file on someone else's Repl from my NodeJS application (maybe like a gallery of different user's projects and it shows project info and project code). Instead of finding the Repl and copy-pasting the code or using webscraping (yuck) there's an actual API to get the contents of a file, and it's easy to use :D!
I hope that makes sense...