pyxero get LineItems on banktransactions - python

I'm running pyxero and trying to get the reference and description from a bank transaction but am having trouble getting it.
I can run:
trans = xero.banktransactions.filter(BankAccount_Name="chosen_account")
Which gives me the transcations and details, however the reference and description are not present.
It also shows the LineItems are empty:
'LineItems': []
I also get the same if I try:
transaction = xero.banktransactions.filter(BankTransactionID=BankTransactionID)
Is there a way to get this information?
Many thanks

Need to use get instead of filter to get the LineItems:
transaction = xero.banktransactions.get(BankTransactionID)

To get all the lineitem detail you either need to :
retrieve a specific item by BankTransactionID (as #blountdj implies in their answer)
OR
use Xero API's built-in paging in the request by passing 'page=xxx' as an optional parameter (which you might need to loop through multiple pages/requests if >100 transactions - which is likely).
Refer Xero API reference re Bank Transaction paging here

Related

api.get_user with Tweepy will not give description

I'm trying to use Tweepy (version 4.4.0) to get a user's description but it's seemingly not working:
u = api.get_user(username='XXXX', user_fields=['description'])
but the output of this is simply:
Response(data=<User id=123 name=XXX username=XXX>, includes={}, errors=[], meta={})
So it's getting me the name and id fine, but it's returning an empty for any user fields.
Note I've also tried with user_auth: 1, but I get 'Unauthorized: 401' - but from what I've seen around, I don't think user authentication is the problem here... but maybe it is?
Any advice would be great!
api seems to be an instance of tweepy.Client here.
From the relevant FAQ section in Tweepy's documentation:
Why am I not getting expansions or fields data with API v2 using Client?
If you are simply printing the objects and looking at that output, the string representations of API v2 models/objects only include the default attributes that are guaranteed to exist.
The objects themselves still include the relevant data, which you can access as attributes or by key, like a dictionary.
The user object being returned in the response should have a description field with the user's description.
You can access the description with: u.data.description
Keep in mind that the description may be blank some times, try with created_at to be sure it works.
Sample code for extracting description of any twitter user is as follows
import tweepy
auth = tweepy.OAuth2BearerHandler(os.environ.get("TWITTER_API_KEY"))
api = tweepy.API(auth)
user = api.get_user(screen_name="TechWiser", include_entities=False)
description = user._json['description']
user._json contain many other key, value pair that you can explore

python-binance: Get all orders, without specifying symbol

Trying to fetch my Binance accounts order history with the python-binance module. There is an option to get all orders within one symbol (see documentation):
orders = client.get_all_orders(symbol='BNBBTC', limit=10)
Bu the problem is I can't pass more than 1coin in the symbol parameter
How can I pass a list for the symbol parameter, I want to fetch more than 1 coins order history in a single function
as I'm trying to build a portfolio for my Binance account. Or is there another method to do so?
Currently it is not possible to get all historical orders or trades without specifying the symbol in one call, even without the module python-binance.
There is an ongoing discussion on the Binance forum, requesting this feature.
As a workaround:
If you know your ordered symbols: Use the function get_all_orders() multiple times for each symbol in a loop.
If you don't know your ordered symbols: you could send a GET request for each symbol available at Binance (as mentioned in the discussion linked above). But be careful with the rateLimits.
I was asking myself the same thing. Well, a work around would be to iterate over all the tickers available in Binance looking for the ones we did traded in the past.
If you are working the free plan of the API, the best would be to setup a storage file or database and store all the result. Then you have to care about keeping with the changes from there.
Yeah, it is exactly how I am going to deal with this.
(edit) :
Sleep function will be needed to avoid more than 1200 queries per minute.
(example) :
def getAllTickers(self):
# Get all available exchange tickers
exchangeInfo = self.client.get_exchange_info()
# Extract the tickers general info
exchangeSymbols = []
for i in exchangeInfo['symbols']:
exchangeSymbols.append(i)
return exchangeSymbols
def getMyTrades(self, strSymbol):
return self.client.get_my_trades(symbol=strSymbol)
def getMyTradedTickers(self):
tickers = self.getAllTickers()
# Extract every ticker where trade happened
traded = []
for i in tickers:
tickerTransactions = self.getMyTrades(i["symbol"])
if tickerTransactions :
traded.append(tickerTransactions)
print(i["symbol"], " transactions available")
else :
print(i["symbol"], " has no transactions")
self.time.sleep(0.1)
return traded
**Srry for the code quality. Python is not my main coding language and im getting use to it.

Fetching place details (specifically reviews) with GooglePlaces in Python 3

I am completely new to this module and Python in general, yet wanted to start some sort of a fun project in my spare time.
I have a specific question concerning the GooglePlaces module for Python - how do I retrieve the reviews of a place by only knowing its Place ID.
So far I have done...
from googleplaces import GooglePlaces, types, lang
google_places = GooglePlaces('API KEY')
query_result = google_places.get_place(place_id="ChIJB8wSOI11nkcRI3C2IODoBU0")
print(query_result) #<Place name="Starbucks", lat=48.14308250000001, lng=11.5782337>
print(query_result.get_details()) # Prints None
print(query_result.rating) # Prints the rating of 4.3
I am completely lost here, because I cannot get access to the object's details. Maybe I am missing something, yet would be very thankful for any guidance through my issue.
If you are completly lost just read the docs :)
Example from https://github.com/slimkrazy/python-google-places:
for place in query_result.places:
# Returned places from a query are place summaries.
# The following method has to make a further API call.
place.get_details()
# Referencing any of the attributes below, prior to making a call to
# get_details() will raise a googleplaces.GooglePlacesAttributeError.
print place.details # A dict matching the JSON response from Google.
See the Problem with your code now?
print(query_result.get_details()) # Prints None
should be
query_result.get_details() # Fetch details
print(query_result.details) # Prints details dict
Regarding the results, the Google Docs states:
reviews[] a JSON array of up to five reviews. If a language parameter
was specified in the Place Details request, the Places Service will
bias the results to prefer reviews written in that language. Each
review consists of several components:

How to query specific information for an issue?

I'm trying to use JIRA python api to receive the list of tickets that have been raised in the last 30 days but whenever i run
Issue = main.jira.issue("PLAT-38592")
i = main.jira.issue(issue, "Summary")
print(i)
All that gets returned is
PLAT-38592
Then i try to poke at the issue
Issue = main.jira.issue("PLAT-38592")
print (Issue)
And all that gets returned is
PLAT-38592
I need to be able receive information from this ticket but it only returns a string
Issues are objects. You can access their content by accessing fields.
If you for example want to access the summary, you can use (according to the docs):
issue = jira.issue('PLAT-38592', fields='summary')
summary = issue.fields.summary
print(summary)

limit TwitterSearch API, python

How would I limit the number of results in a twitter search?
This is what I thought would work...tweetSearchUser is user input in another line of code.
tso = TwitterSearchOrder() # create a TwitterSearchOrder object
tso.set_keywords(["tweetSearchUser"]) # let's define all words we would like to have a look for
tso.setcount(30)
tso.set_include_entities(False) # and don't give us all those entity information
Was looking at this reference
https://twittersearch.readthedocs.org/en/latest/advanced_usage_ts.html
tried this, seems like it should work but can't figure out the format to enter the date...
tso.set_until('2016-02-25')
You should use set_count as specified in the documentation.
The default value for count is 200, because it is the maximum of tweets returned by the Twitter API.

Categories