|
| 1 | +> ⚠️ **IMPORTANT**: ReplAPI.it is now in version 2.x! Any projects transitioning to 2.x should read through [this](https://github.com/RayhanADev/ReplAPI.it/releases/tag/v2.0.6). ⚠️ |
| 2 | +
|
1 | 3 | [![Contributors][contributors-shield]][contributors-url] |
2 | 4 | [![Forks][forks-shield]][forks-url] |
3 | 5 | [![Stargazers][stars-shield]][stars-url] |
|
60 | 62 | <!-- ABOUT THE PROJECT --> |
61 | 63 | ## About The Project |
62 | 64 |
|
63 | | -[](https://replit.com/@RayhanADev/REPLAPIit-Replit-API-Package) |
| 65 | +[](https://replit.com/@RayhanADev/ReplAPIit) |
64 | 66 |
|
65 | 67 | The Replit GraphQL API is an extraordinary way to make projects unique and special, yet with the numerous packages available few such projects have been made. Why would that be? Most likely due to how complicated writing code can get and the limitations of their queries. My package, **ReplAPI.it**, changes that with a simple to use structure and many queries, some of which are: |
66 | 68 |
|
67 | 69 | * Queries for Data on Users (such as Profile, Posts, Comments) |
68 | 70 | * Queries for Data on Posts (such as Upvoters, Content) |
69 | | -* Queries for Data on Notifications (such as Reply Notifications, Achievement Notifications) |
| 71 | +* Queries for Data on Repls (such as Files, Comments) |
70 | 72 | * Mutations for Commenting, Reporting, and Posting |
71 | 73 | * Queries for Data on Leaderboard (with filters such as cycles since) |
72 | 74 | * and lots more! |
@@ -97,48 +99,60 @@ If you have not already download npm: |
97 | 99 | ``` |
98 | 100 | 2. Require the package in your code |
99 | 101 | ```js |
100 | | - const repl = require('replapi-it'); |
| 102 | + import ReplAPI from 'replapi-it'; |
| 103 | + ``` |
| 104 | +3. Initilize the package |
| 105 | + ```js |
| 106 | + const replapi = ReplAPI({ |
| 107 | + username: 'your-username-here' |
| 108 | + }); |
101 | 109 | ``` |
102 | 110 |
|
103 | 111 | ## Usage |
104 | 112 |
|
105 | 113 | Using ReplAPI.it is very simple! Let's create a simple user and ask for their cycles: |
106 | 114 | ```js |
107 | | - const repl = require('replapi-it'); |
108 | | - |
109 | | - const myUser = new repl.User("RayhanADev"); |
| 115 | + import ReplAPI from 'replapi-it |
| 116 | + const replapi = ReplAPI({ |
| 117 | + username: 'your-username-here' |
| 118 | + }); |
| 119 | + |
| 120 | + const myUser = new replapi.User("RayhanADev"); |
110 | 121 |
|
111 | 122 | async function getCycles() { |
112 | | - let info = await myUser.profileData(); |
113 | | - let cycles = info.karma; // Yep, it's karma! |
114 | | - console.log(`User Cycles: ${cycles}`) |
| 123 | + let info = await myUser.userGraphQLDataFull(); |
| 124 | + let cycles = info.karma; // Yep, it's karma! |
| 125 | + console.log(`User Cycles: ${cycles}`) |
115 | 126 | } |
116 | 127 |
|
117 | 128 | getCycles() |
118 | 129 | ``` |
119 | 130 |
|
120 | 131 | Output: |
121 | | - ```sh |
| 132 | + ``` |
122 | 133 | User Cycles: 1008 |
123 | 134 | ``` |
124 | 135 |
|
125 | 136 |
|
126 | 137 | That was fun! Now how about getting a specific post? Let's create a simple post and ask for it's title: |
127 | 138 | ```js |
128 | | - const repl = require('replapi-it'); |
| 139 | + import ReplAPI from 'replapi-it |
| 140 | + const replapi = ReplAPI({ |
| 141 | + username: 'your-username-here' |
| 142 | + }); |
129 | 143 |
|
130 | | - const myPost = new repl.Post(78043); |
| 144 | + const myPost = new replapi.Post(78043); |
131 | 145 |
|
132 | 146 | async function getTitle() { |
133 | | - let info = await myPost.postData(); |
134 | | - let title = info.title; |
135 | | - console.log(`Post Title: ${title}`) |
| 147 | + let info = await myPost.postDataFull(); |
| 148 | + let title = info.title; |
| 149 | + console.log(`Post Title: ${title}`) |
136 | 150 | } |
137 | 151 | |
138 | 152 | getTitle() |
139 | 153 | ``` |
140 | 154 | Output: |
141 | | - ```sh |
| 155 | + ``` |
142 | 156 | Post Title: Presenting... 🤔 RayhanADev 🤔? (GraphQL Success!) |
143 | 157 | ``` |
144 | 158 |
|
|
0 commit comments