Get data from Scroll in http request api elasticsearch - python

I'm trying to write a code in python to get all the data from an api through an http request.
I am wondering if there is a way to use the _scroll_id and it's contents in python. If so, how do I implement it or could you share some documentation regarding it?
All the documentation regarding elasticsearch in python is using a localhost...
Any leads would be highly appreciated.

Elasticsearch has a Python library that helps with pinging the database.
You can use the scan() helper function. Internally, it calls the scroll API so you don't have to worry about any of that.
For the last part of your question, you'd have to follow the tutorial to see how to connect to different databases.
https://elasticsearch-py.readthedocs.io/en/v8.3.3/helpers.html#scan

Related

KIbana connection and ES integration using python

This project basically involved Elasticsearch cloud and Kibana, and Python client as well. Currently, I am stuck trying to add an index pattern to Kibana from ES. I found some helpful functions by pybana such as "update_or_create_default_index_pattern" but nothing related to Kibana connection.
I would appreciate it if someone have ever worked with this tool using python (or whatever programming language)
Thank you
You can use the kibana index pattern API.
With the python requests package (or any other HTTP library), you can create an HTTP request for creating the index pattern.
Create index pattern API

Getting data from some rest API on Django

So here's the deal:
I have some nodeJS/PHP rest API! And I need to build a Django app which feeds on that API. Everything will be done on the server-side! So I would not use Django's back-end structure.
Basically I would GET some JSONs and POST it back so the server, which in turn would process that data. How should I proceed? I've been looking for tutorials for a while now.
However everywhere I look, people are using django-rest or something "django friendly". I tried to start using python-requests but it is still kind of cloudy, am I letting my front-end unprotected using direct GET/POST calls to the server (using requests)!?
Any guidance would be much appreciate!

Accessing MongoDB Database on nodejs server using HTTP GET requests

I have a nodejs server setup on AWS with mongoDB. I want to access the database contents using GET method. There is another application in python which needs to access this database present on AWS. I searched on the internet and came across PycURL but I am not getting how to use it exactly. How to approach with pycURL or what can be an alternate solution?
You can build your restful API that is going to handle those GET requests. You have awesome tutorial (with example that you want on bottom):
https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4
Edit: If you want phyton code for GET requests there is awesome answer here: Simple URL GET/POST function in Python
Edit 2: Example of how would this work. You first need to code your API how to handle GET request and on what route (example: http://localhost:5000/api/getUsers). Than you want to make GET request to that route using Phyton:
Example:
r = requests.get(url="http://localhost:5000/api/getUsers")
I had a similar problem a while ago, there is a tutorial here here. It can lead you towards your intended direction, the drawback may be that in the tutorial, to issue the http request (if I remember correctly), they used postman but I'm sure you can still use PyCurl.

Review Board Python Web API

I'm new with using third-party APIs, and I was trying to get the Review Board Web API to work in python.
However, I was confused about 3 things:
from rbtools.api.client import RBClient
client = RBClient('http://localhost:8080/')
root = client.get_root()
My first question: is http://localhost:8080/ the server that is running the ReviewBoard server? Is there some sort of test server that I can use instead of running my own?
Again, I don't have much experience with APIs so I was wondering if I needed to do some form of authentication before making these calls.
Finally, if I must set up my own Review Board server to try out the API. Would it be possible to get some code for a very simple example as to how to make the simplest POST and GET request you can think of with minimal setup if for example my server was running on http://localhost:8080/?
Reference : http://www.reviewboard.org/docs/rbtools/0.5/api/overview/
To answer your first question: the answer seems to be yes although their docs don't make it entirely clear.
Their docs say:
Here is an example of how to instantiate the client, and retrieve the Root List Resource resource:
Before the code snippet your pasted. That makes me think that the url being passed is whatever you're trying to use, e.g., you could have that set up on a networked machine called monty_python running on port 5050, then you would do:
client = RBClient('http://monty_python:5050/')
As for a test server you should check the documentation they have about their Web API.
Their examples don't seem to show any authentication being performed in the overview. If you check in other sections (e.g., Tutorial: Creating a Pull Request) you'll see them demonstrate how to authenticate and what can be done after authenticating.
As for your last question, I'm not 100% sure what you're asking, but you should probably check the docs I found for their Web API

Trying to send data to Google Analytics with Measurement Protocol

So, I'm trying to send data to GA using their Measurement Protocol with Python. From what I can gather, I will be sending POST requests via HTTP, but I'm not sure where to start. The data will likely be coming from an API or Database.
My project is inspired by this video if it gives you a better idea: http://www.elisa-dbi.co.uk/blog/tracking-wemo-switch-motion-google-universal-analytics/
I guess I'm creating a wrapper, but I'm unclear to what exactly that is. Any advice or input would be greatly appreciated.
Thanks!
You can go throught the following documentation to send HTTP POST requests to google analytics
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
By now you have probably already created your wrapper, but for what its worth, my firm has recently released a library under BSD license, with an API similar to that of Google's analytics.js.
https://github.com/analytics-pros/universal-analytics-python

Categories