Skip to content

Commit ad8f8e0

Browse files
Update README with Quick Start
1 parent 9f92d2b commit ad8f8e0

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,73 @@
11
# Judge0 Python SDK
22

33
The official Python SDK for Judge0.
4+
```python
5+
>>> import judge0
6+
>>> result = judge0.run(source_code="print('hello, world')")
7+
>>> result.stdout
8+
'hello, world\n'
9+
>>> result.time
10+
0.987
11+
>>> result.memory
12+
52440
13+
>>> for f in result:
14+
... f.name
15+
... f.content
16+
...
17+
'script.py'
18+
b"print('hello, world')"
19+
```
20+
21+
## Installation
22+
23+
```bash
24+
pip install judge0
25+
```
26+
27+
### Requirements
28+
29+
- Python 3.9+
30+
31+
## Quick Start
32+
33+
### Getting The API Key
34+
35+
Get your API key from [Sulu](https://platform.sulu.sh/apis/judge0), [Rapid](https://rapidapi.com/organization/judge0), or [ATD](https://www.allthingsdev.co/publisher/profile/Herman%20Zvonimir%20Do%C5%A1ilovi%C4%87).
36+
37+
#### Notes
38+
39+
* [**Recommended**] Choose Sulu if you need pay-as-you-go (pey-per-use) pricing.
40+
* Choose Rapid or ATD if you need a quota-based (volume-based) plan.
41+
* Judge0 has two flavors: Judge0 CE and Judge0 Extra CE, and their difference is just in the languages they support. When choosing Sulu, your API key will work for both flavors, but for Rapid and ATD you will need to explicitly subscribe to both flavors if you want to use both.
42+
43+
### Using Your API Key
44+
45+
#### Option 1: Explicit Client Object
46+
47+
Explicitly create a client object with your API key and pass it to Judge0 Python SDK functions.
48+
49+
```python
50+
import judge0
51+
client = judge0.SuluJudge0CE(api_key="xxx")
52+
result = judge0.run(client=client, source_code="print('hello, world')")
53+
print(result.stdout)
54+
```
55+
56+
Other options include:
57+
- `judge0.RapidJudge0CE`
58+
- `judge0.ATDJudge0CE`
59+
- `judge0.SuluJudge0ExtraCE`
60+
- `judge0.RapidJudge0ExtraCE`
61+
- `judge0.ATDJudge0ExtraCE`
62+
63+
#### Option 2: Implicit Client Object
64+
65+
Put your API key in one of the following environment variables, respectable to the provider that issued you the API key: `JUDGE0_SULU_API_KEY`, `JUDGE0_RAPID_API_KEY`, or `JUDGE0_ATD_API_KEY`.
66+
67+
Judge0 Python SDK will automatically detect the environment variable and use it to create a client object that will be used for all API calls if you do not explicitly pass a client object.
68+
69+
```python
70+
import judge0
71+
result = judge0.run(source_code="print('hello, world')")
72+
print(result.stdout)
73+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy