Context
<p dir="auto"><a href="/@felixxx/python-requests-for-hive-json-rpc">I wrote a post, where I demonstrated how to build calls for Hive's JSON-RPC endpoints.<br />
To show that this can have certain benefits over using predefined libraries like BEEM, I came up with an example, that can do one particular job faster than BEEM.
<p dir="auto">To keep the post short and tight, I did not comment too much.<br />
Writing such posts isn't easy, because I never know, who reads them.<br />
For some people everything code is like magic. For others, the stuff I work on seems so far below their level, that they don't even understand my problems.
<p dir="auto">But this time, I had a reader. Someone who also tested my examples.<br /><span>
Thanks <a href="/@arc7icwolf">@arc7icwolf!
<p dir="auto">He tested the examples and then went ahead and tried building his own calls, based on <a href="https://developers.hive.io/apidefinitions/#json-rpc-api" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Hive's developer information.<br />
That's exactly what I intended: enabling readers to explore that on their own.
<p dir="auto">He has since run into problems and <a href="/@arc7icwolf/re-felixxx-sjrrqu">replied to me.
<p dir="auto">Here is my attempt to demonstrate my workflow with this stuff....
<h2><code>get_discussions_by_author_before_date
<p dir="auto"><span><a href="https://developers.hive.io/apidefinitions/#condenser_api.get_discussions_by_author_before_date" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://developers.hive.io/apidefinitions/#condenser_api.get_discussions_by_author_before_date
<p dir="auto">Another great example for how incomplete these docs are.<br />
The expected JSON response according to the docs is: <code>[]<br />
An empty list. 😡 ...what a useful call! The response is a constant <code>[]
<p dir="auto">I don't like anything <code>get_discussions - I had trouble with those before.<br />
<a href="/@felixxx/hive-api-reference-incomplete">I raged about this stuff...<br />
The higher level functions, that precompile data a specific way, seem to get worse the more abstract they are. Generally, for beginners, I'd recommend sticking to <code>block_api and <code>account_history_api and other low level, core features.
<p dir="auto">But I think we can make it work... (I am building as I write)
<h2>Parameters
<p dir="auto">In my last dev post, I used <code>database_api.get_dynamic_global_properties, which takes no parameters. That makes it easy to demonstrate the concept with.
<p dir="auto"><code>get_discussions_by_author_before_date takes parameters, and again the docs aren't helpful:
<p dir="auto">Query Parameters JSON: <code>["", "", "1970-01-01T00:00:00", 100]<br />
Why publish these docs and leave them empty? 😡
<p dir="auto">Anyways, I assume it takes at least 4 parameters.<br />
3 strings and one integer.<br />
The example from the docs provides more help:
<p dir="auto"><code>"params":["hiveio","firstpost","2016-04-19T22:49:43",1]
<p dir="auto">I have done this before, so I have an idea, how that's supposed to work.<br />
Without more context or prior knowledge, that API is unusable like this though.<br />
What anyone can see: the call takes 4 different parameters.
<ul>
<li><code>hiveio (string)- an account name
<li><code>firstpost (string) - That's a post identifier
<li><code>2016-04-19T22:49:43 (string) - that's a date in a specific format
<li><code>1 (integer) - that's the batch size, most likely (1 will return a list with 1 item)
<h2>Example Parameters
<p dir="auto">For a test shot, I will simply use fixed parameters.
<p dir="auto"><code>"params":["felixxx","python-requests-for-hive-json-rpc","2024-09-14T10:00:00",10]
<ul>
<li><code>felixxx - that's me!
<li><code>python-requests-for-hive-json-rpc - an identifier of a post of mine
<li><code>2024-09-14T10:00:00 - today, 10 AM (blockchain runs on UTC)
<li><code>10 - batch size of 10.
<h3>Test Code
<pre><code>import requests
url = 'https://api.hive.blog'
params_string = '"params":["felixxx","python-requests-for-hive-json-rpc","2024-09-14T10:00:00",10]'
data = '{"jsonrpc":"2.0", "method":"condenser_api.get_discussions_by_author_before_date", '+ params_string + ',"id":1}'
response = requests.post(url, data=data)
print(response.json())
<blockquote>
<p dir="auto">I am not using f strings. I prefer to use <code>+ operator to manipulate strings.<br />
That is not recommended, but I find it easier to read, use and understand.<br />
Generally considered as poor code, though.
<p dir="auto">That gives me a response, which looks like a list of 'discussion' objects or something.
<p dir="auto">You can define a start- and end-point by using the date and post-identifier, much like here:<br /><br />
...to collect more data than the batch size allows.<br />
I am a bit too annoyed to explain the details right here...<br />
I am not getting paid for any of this...<span>
<a href="https://peakd.com/@felixxx/hive-api-reference-incomplete" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://peakd.com/@felixxx/hive-api-reference-incomplete
<h2>Conclusion
<p dir="auto">I made the function work. It's a useless function, it seems.
<p dir="auto">I didn't know how this would end, as I coded it while writing this post.<br />
I made it work, but have no real idea what the response data represents.<br />
I have also no desire to waste any more time exploring this call.<br /><span>
I hope it works as an example for <a href="/@arc7icwolf">@arc7icwolf and helps him along his path.
<p dir="auto"><br />
It took years, cost a fortune, nobody bothered documenting it properly.<br />
At the time, I was so impressed by these developers.<br />
Now that I caught up a little, I think much less of them.<span><a href="/@vandeberg">@vandeberg built this.
<p dir="auto"><br />
I am sure they are building great things this time. 🤣<span>Most of them went to a different company and work for <a href="/@andrarchy">@andrarchy now.
Thanks for taking the time to explore this method: following your workflow is already very useful for me, as it helps me understand if I was doing something right or if I was completely off-road.
I'm doing some progress with my scripts and it's all thanks to you! I know that my stuff is very basic, but if I can keep doing even small progress I'm sure one day I will be able to look back and be surprised of how much better I have become :)
i run into same problems, 2 years ago
Date is not used! Here you find this information:
https://developers.hive.io/tutorials-recipes/paginated-api-methods.html#tags_apiget_discussions_by_author_before_date
You wrote this, 2 years ago:
Do you understand pagination?
Yes. You have to add last permlink you get in results, to get the next 10.
I was too lazy to type, asked chatGPT, but then he set permlink as 3rd parameter instead of 2nd. But I noticed it and here is the correct code:
https://jsfiddle.net/hive_coding/5wfojx4u/
So you can only ever get to the next 10 (or however many you call up).
Something like (1 2 3 4 5 .... 10 ): jump to the 5th page, is not possible, unless you already make all calls and always remember the permlink.
Thats why i would prefere HiveSQL for Calls getting informations link this.
'Yes' would have been enough.
!LOL
lolztoken.com
It was a case of age-related macaroni degeneration.
Credit: reddit
$LOLZ on behalf of mein-senf-dazu
(3/8)
Farm LOLZ tokens when you Delegate Hive or Hive Tokens.
Click to delegate: 10 - 20 - 50 - 100 HP@felixxx, I sent you an