Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: REST API python examples update #896

Merged
merged 4 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions _includes/rest/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/AppOpened
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/AppOpened', json.dumps({
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/AppOpened', '', {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand Down Expand Up @@ -73,22 +75,25 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Search
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Search', json.dumps({
"dimensions": {
"priceRange": "1000-1500",
"source": "craigslist",
"dayType": "weekday"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
"dimensions": {
"priceRange": "1000-1500",
"source": "craigslist",
"dayType": "weekday"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand All @@ -108,20 +113,23 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Error
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Error', json.dumps({
"dimensions": {
"code": "404"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
"dimensions": {
"code": "404"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand Down
41 changes: 23 additions & 18 deletions _includes/rest/cloud-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>functions/hello
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>functions/hello', json.dumps({
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>functions/hello', '', {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand All @@ -47,17 +49,20 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>jobs/userMigration
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>jobs/userMigration', json.dumps({
"plan": "paid"
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>",
"Content-Type": "application/json"
})
"plan": "paid"
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>
15 changes: 9 additions & 6 deletions _includes/rest/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ curl -X GET \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>config
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('GET', '<span class="custom-parse-server-mount">/parse/</span>config', '', {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>"
})
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand Down
80 changes: 46 additions & 34 deletions _includes/rest/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/hello.txt
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>files/hello.txt', 'Hello, World!', {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "text/plain"
})
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "text/plain"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand Down Expand Up @@ -55,16 +58,19 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/pic.jpg
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>files/pic.jpg', open('myPicture.jpg', 'rb').read(), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "image/jpeg"
})
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "image/jpeg"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand All @@ -89,23 +95,26 @@ curl -X POST \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>classes/PlayerProfile
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>classes/PlayerProfile', json.dumps({
"name": "Andrew",
"picture": {
"name": "...profile.png",
"url:": "...profile.png",
"__type": "File"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
"name": "Andrew",
"picture": {
"name": "...profile.png",
"url:": "...profile.png",
"__type": "File"
}
}), {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand All @@ -124,15 +133,18 @@ curl -X DELETE \
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/...profile.png
</code></pre>
<pre><code class="python">
import json,httplib
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
import http.client
import json


connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
connection.connect()
connection.request('DELETE', '<span class="custom-parse-server-mount">/parse/</span>files/...profile.png', '', {
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>"
})
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>"
})
result = json.loads(connection.getresponse().read())
print result
print(result)
</code></pre>
</div>

Expand Down
Loading