How to update node in Python osmapi?

Hello. I would like to update OpenStreetMap with Python using osmapi module.

I wanted update name of node 6258337521 from value “Biblioteka Miejska w Łodzi Filia nr 63” to value “Biblioteka Miejska w Łodzi, Filia nr 63” (in English: “City Library in Lodz, Branch No. 63”)

Below is IPython session:


In [1]: from osmapi import OsmApi

In [2]: myApi = OsmApi(username="jrk", password="********")

In [3]: myApi.ChangesetCreate({u"comment": u"Dodanie przecinka w nazwie"})

Out[3]: 79355591

In [4]: f63 = myApi.NodeGet('6258337521')

In [5]: f63

Out[5]:
{'id': 6258337521,
 'visible': True,
 'version': 2,
 'changeset': 72857560,
 'timestamp': datetime.datetime(2019, 7, 31, 13, 39, 34),
 'user': 'BMwL',
 'uid': 9655269,
 'lat': 51.7672921,
 'lon': 19.4787142,
 'tag': {'addr:city': 'Łódź',
  'addr:country': 'PL',
  'addr:housenumber': '75',
  'addr:postcode': '90-031',
  'addr:street': 'Tuwima',
  'amenity': 'library',
  'contact:email': 'filia_63@biblioteka.lodz.pl',
  'contact:phone': '+48 42 674 48 73',
  'name': 'Biblioteka Miejska w Łodzi Filia nr 63',
  'operator': 'Biblioteka Miejska w Łodzi',
  'wheelchair': 'no'}}

In [6]: myApi.NodeUpdate({'id': 6258337521, 'lat': f63['lat'], 'lon': f63['lon'], 'version': f63['version'], 'tags': {'name': 'Biblioteka Miejska w Łodzi, Filia nr 63'} })

Out[6]:
{'id': 6258337521,
 'lat': 51.7672921,
 'lon': 19.4787142,
 'version': 3,
 'tags': {'name': 'Biblioteka Miejska w Łodzi, Filia nr 63'},
 'changeset': 79355591}

In [7]: myApi.ChangesetClose()

Out[7]: 79355591

In [8]:

Changeset was saved, but unfortunately without my change. What did I do wrong?

https://www.openstreetmap.org/node/6258337521
https://www.openstreetmap.org/changeset/79355591

Best regards,
jrk

OK, I managed to find out how to do it. it was a typo, I wrote “tags” instead of “tag”.

Here is the code that works:

from osmapi import OsmApi

myApi = OsmApi(username='jrk', password='********')

myApi.ChangesetCreate({'comment': 'Added opening_hours tag'})

node = myApi.NodeGet('6665468241')

tag = node['tag']
tag['opening_hours'] = 'Mo 11:00-15:00; We 09:00-14:00; Fr 11:00-15:00'
tag['opening_hours:url'] = 'https://www.biblioteka.lodz.pl/znajdz-filie/'

myApi.NodeUpdate({
    'id': 6665468241,
    'lat': node['lat'],
    'lon': node['lon'],
    'version': node['version'],
    'tag': tag })

myApi.ChangesetClose()

Two remarks: